Advertisement
Guest User

Untitled

a guest
Oct 20th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4.     <title>Ejercicio </title>
  5. </head>
  6. <body>
  7.     <script type="text/javascript">
  8.  
  9.  
  10.        
  11.         function binario(n) {
  12.  
  13.             var array = [];
  14.            
  15.             while (n <= 1) {
  16.  
  17.                 div = n / 2;
  18.                 rest = n % 2;
  19.  
  20.                 array.push(rest);
  21.  
  22.                 n = div;
  23.  
  24.                 bi = array.join("");
  25.  
  26.             }
  27.             alert(bi);
  28.            
  29.  
  30.         }
  31.  
  32.         binario(8);
  33.  
  34.     </script>
  35.  
  36. </body>
  37. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement