mituri

[C++] Najmniejsza wielokrotnosc

Oct 1st, 2015
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. /*
  2. Project Euler("https://projecteuler.net/archives")
  3. Problem 5
  4.  
  5. 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
  6. What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
  7. */
  8.  
  9. int main(){
  10.  
  11. int num = 0, size = 10;
  12. bool check = true;
  13. for(int i = 1; i < 1000000000; i++){
  14. for(int j = 1; j < 20; j++){
  15. if(i%j != 0 ) check = false;
  16. }
  17. if(check == true) cout << i << endl;
  18. check = true;
  19. }
  20. system("PAUSE");
  21. }
Advertisement
Add Comment
Please, Sign In to add comment