Guest User

Untitled

a guest
Jan 23rd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head > <h3 align="center">Euler Question 1 </h3></head>
  4. <body>
  5. <p align="center"> The sum of the variables below 1000 which are either multiples of 3 or 5:</p>
  6. <b> <p align="center" id="add"></p> </b>
  7. <script>
  8. var multiples_sum = 0; //multiples_sum is initialized to zero
  9. for (var a = 0; a < 1000; a++) //condition for considering the varibles below 1000, 'a' be the variable
  10. {
  11. if (a % 3 == 0 || a % 5 == 0) //if condition to check the multiples of 3 or 5
  12. multiples_sum += a; //sum is incremented if the 'if' condition satifies
  13. }
  14. document.getElementById("add").innerHTML = multiples_sum;
  15. </script>
  16. </body>
  17.  
  18. </html>
Add Comment
Please, Sign In to add comment