Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <body>
  4. <input type="text" id="x"></input>
  5. <input type="button" value="licz silnie" onclick="funk()"></input>
  6. <p id="wynik"></p>
  7.  
  8. <script>
  9. function funk()
  10. {
  11. var a=document.getElementById("x").value;
  12. if (a<=20 && a>=0 && a%1==0)
  13. {
  14. if (a=="" || a==null)
  15. document.getElementById("wynik").innerHTML="podaj liczbe"
  16. else
  17. {
  18. if (a==0 || a==1)
  19. document.getElementById("wynik").innerHTML="1"
  20. else
  21. {
  22. var b=a;
  23. for (var i=a;i>=2;i--)
  24. {
  25. b=b*(a-1);
  26. a--;
  27. }
  28. document.getElementById("wynik").innerHTML=b;
  29. }
  30. }
  31. }
  32. else
  33. {
  34. if (a>20)
  35. document.getElementById("wynik").innerHTML="za duza liczba"
  36. if (a%1!=0)
  37. document.getElementById("wynik").innerHTML="liczba musi byc calkowita"
  38. if (a<0)
  39. document.getElementById("wynik").innerHTML="liczba nie moze byc ujemna"
  40. if (a*1!=a)
  41. document.getElementById("wynik").innerHTML="zle dane"
  42. }
  43. }
  44. </script>
  45. </body>
  46. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement