Abdulg

Project Euler #5 (For-loop brute forcing)

Mar 11th, 2014
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.38 KB | None | 0 0
  1. //Compiled under Crunchbang GNU/Linux using g++
  2.  
  3. #include<iostream>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     bool Done;
  9.     for (int i = 100; i > 0; i++)
  10.     {
  11.         Done = true;
  12.         for (int n = 1; n <= 20; n++) if (i%n != 0) Done = false;
  13.         if (Done == true)
  14.         {
  15.             cout << i << endl;
  16.             break;
  17.         }
  18.     }
  19.     return 0;
  20. }
  21.  
  22. /*
  23. user@computer:~/Programming$ ./SmallestMultiple
  24. 232792560
  25. */
Advertisement
Add Comment
Please, Sign In to add comment