Facebook
From Gentle Lion, 5 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 233
  1. <!DOCTYPE html>
  2. <head>
  3.       <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2" />
  4.       <meta http-equiv="Content-Language" content="pl" />
  5.       <title>JavaScript zadanie</title>
  6.           <link rel="stylesheet" type="text/css" href="style.css">
  7. </head>
  8. <body>
  9.         <div>
  10.                 <b> Potega - metoda rekurencyjna </b>
  11.         </div>
  12.         <script>
  13.                 function potega_r(x)
  14.                 {
  15.                         if(x==0) return 1;
  16.                         return 2*potega_r(--x);
  17.                 }
  18.                 a = Math.floor(Math.random() * 6);
  19.                 document.write("2^",a,"=",potega_r(a));
  20.         </script>
  21.         <div>
  22.                 <b> Potega - metoda iteracyjna </b>
  23.         </div>
  24.         <script>
  25.                 function potega_i(x)
  26.                 {
  27.                         var y=1
  28.                         for(i=1;i<=x;i++) {
  29.                                  y=y*2
  30.                                  }
  31.                         return y
  32.                 }
  33.                 a = Math.floor(Math.random() * 6);
  34.                 document.write("2^",a,"=",potega_i(a));
  35.         </script>
  36. </body>
  37. </html>
  38.