Posted By

mju4t on 02/03/11


Tagged

project Euler


Versions (?)

Project Euler Problem 1


 / Published in: C++
 

Sorted by problem ID.

  1. /*
  2. Alexander DeTrano
  3. 2/1/2010
  4. Project Euler - Problem 1
  5.  
  6. Add all the natural numbers below one thousand that are multiples of 3 or 5.
  7. */
  8.  
  9. #include <iostream>
  10.  
  11. using namespace std;
  12.  
  13. int main()
  14. {
  15. int x =0; int z=0;
  16. for (int i=0;i<1000;i++){
  17. if ( i%3 == 0||i%5 == 0){
  18. z=i + z;
  19. }
  20. }
  21. cout<<"z= " << z <<"\n";
  22.  
  23. }

Report this snippet  

You need to login to post a comment.