Toggle navigation
Home
Latest pastes
FAQ
Random
BitBin is shutting down!
Register
Login
Euler #12
SUBMITTED BY:
Guest
DATE:
Jan. 24, 2014, 9:05 a.m.
FORMAT:
Text only
SIZE:
601 Bytes
Raw
Download
Tweet
HITS:
957
Go to comments
Report
#include <iostream>
using namespace std;
bool countdiv500(int x);
int main()
{
for(int i = 1; ;i++)
{
int tn = (i * (i + 1)) / 2;
cout << "\n" << tn << " -- " << i;
if(countdiv500(tn))
{
cout << "\nRequired number: " << tn;
break;
}
}
cout << "\n";
return 0;
}
bool countdiv500(int x)
{
int count = 0, i = 1;
while(i != x)
{
if(x % i == 0)
{
count++;
}
if(count == 500)
{
return 1;
break;
}
i++;
}
return 0;
}
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus