Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 0.52 KB | None | 0 0
  1. <html>
  2. <head>
  3. </head>
  4. <body>
  5. <input type+"text" id="a"> <button type="button" id="button">ok!</button>
  6. <div id="tekst"></div>
  7.  
  8. <script type="text/javascript">
  9.  
  10. document.getElementById('"button"').onClick;
  11. const p = 6;
  12. const e=0.0001;
  13. var  x;
  14. var a = document.getElementById('"a"').value;
  15. if (a<0)
  16. {
  17. document.getElementById("tekst").html("Podaj a większe od zera");
  18. }
  19. else
  20. {
  21.     do
  22.     {
  23.         x=p;
  24.         p=(x+a/x)/2;
  25.     }
  26.     while (abs(p-x)>e;
  27. }
  28. document.writeln('Pierwiastkiem jest: ' +p);
  29. }
  30. </script>
  31. </body>
  32. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement