Advertisement
Guest User

Untitled

a guest
May 25th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1.     int factors = 1;
  2.     int currentMaxNatNum = 1;
  3.     while(factors < 500)
  4.     {
  5.         factors = 1;
  6.         int triangleNumber = 0;
  7.         for(int i = 1; i < currentMaxNatNum; i++)
  8.         {
  9.             triangleNumber += i;
  10.         }
  11.        
  12.         for(int i = 1; i < (triangleNumber / 2)+1; i++)
  13.         {
  14.             if(triangleNumber % i == 0)
  15.             {
  16.                 factors++;
  17.             }
  18.         }
  19.  
  20.         currentMaxNatNum++;
  21.         cout<<factors<<endl;
  22.         if(factors >= 500){
  23.         cout << triangleNumber<<" "<<factors << endl;
  24.         }
  25.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement