Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int factors = 1;
- int currentMaxNatNum = 1;
- while(factors < 500)
- {
- factors = 1;
- int triangleNumber = 0;
- for(int i = 1; i < currentMaxNatNum; i++)
- {
- triangleNumber += i;
- }
- for(int i = 1; i < (triangleNumber / 2)+1; i++)
- {
- if(triangleNumber % i == 0)
- {
- factors++;
- }
- }
- currentMaxNatNum++;
- cout<<factors<<endl;
- if(factors >= 500){
- cout << triangleNumber<<" "<<factors << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement