still its not running
??
Code:
#include <stdio.h>
unsigned sum_of_divisors(unsigned n) {
int result=1;
unsigned k;
for( k=2;k*k<=n;++k) {
if(n%k==0) {
int sum_of_powers=1, power=1;
do {
power*=k;
sum_of_powers+=power;
n/=k;
} while(n%k==0);
result*=sum_of_powers;
}
}
return n>1? (n+1)*result : result;
}
bool is_abundant(unsigned n) {
// The body of this function can be substituted by simply
// return sum_of_divisors(n)>2*n;
// This is a memoized version.
const int cache_size=1000000;
static char cache[cache_size]={0};
if(n<cache_size && cache[n])
return cache[n]-1;
bool result=(sum_of_divisors(n)>2*n);
if(n<cache_size)
cache[n] = 1+result;
return result;
}
void print_if_sum_of_abundants(unsigned n) {
unsigned i;
for(i=1;i*2<=n;++i) {
if(is_abundant(i)&&is_abundant(n-i)) {
printf("%d=%d+%d\n",n,i,n-i);
return;
}
}
}
int main() {
int limit;
printf(" "Enter limit: ");
scanf("%d",&limit);
unsigned i;
for(i=1;i<=limit;++i)
print_if_sum_of_abundants(i);
}