Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- </head>
- <body>
- <h1>Wypisanie parzystych lub nieparzystych liczb z przedziału</h1>
- <label>Pierwsza liczba: <input type="text" id="a"></label></br></br>
- <label>Druga liczba: <input type="text" id="b"></label></br></br>
- <input type="button" value="Wypisz parzyste" onclick="parzyste()">
- <input type="button" value="Wypisz nieparzyste" onclick="nieparzyste()">
- <script>
- function parzyste(){
- var a = document.getElementById("a").value;
- var b = document.getElementById("b").value;
- a=parseInt(a);
- b=parseInt(b);
- if(a%2!=0) a+=1;
- while(a<=b)
- {
- document.write(a+"</br>");
- a+=2;
- }
- }
- function nieparzyste(){
- var a = document.getElementById("a").value;
- var b = document.getElementById("b").value;
- a=parseInt(a);
- b=parseInt(b);
- if(a%2==0) a+=1;
- while(a<=b)
- {
- document.write(a+"</br>");
- a+=2;
- }
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement