Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <body>
- <input type="text" id="x"></input>
- <input type="button" value="licz silnie" onclick="funk()"></input>
- <p id="wynik"></p>
- <script>
- function funk()
- {
- var a=document.getElementById("x").value;
- if (a<=20 && a>=0 && a%1==0)
- {
- if (a=="" || a==null)
- document.getElementById("wynik").innerHTML="podaj liczbe"
- else
- {
- if (a==0 || a==1)
- document.getElementById("wynik").innerHTML="1"
- else
- {
- var b=a;
- for (var i=a;i>=2;i--)
- {
- b=b*(a-1);
- a--;
- }
- document.getElementById("wynik").innerHTML=b;
- }
- }
- }
- else
- {
- if (a>20)
- document.getElementById("wynik").innerHTML="za duza liczba"
- if (a%1!=0)
- document.getElementById("wynik").innerHTML="liczba musi byc calkowita"
- if (a<0)
- document.getElementById("wynik").innerHTML="liczba nie moze byc ujemna"
- if (a*1!=a)
- document.getElementById("wynik").innerHTML="zle dane"
- }
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement