Project Euler #171: Finding numbers for which the sum of the squares of the digits is a square

  • + 1 comment

    include

    include

    include

    include

    int main() { unsigned long i,j,n,squares_of_sum=0,sum=0,rem,square=0,temp; scanf("%d",&n); for(i=1;i<=n;i++) { temp=i; while(temp) { rem=temp%10; sum=(sum+(rem*rem)); temp/=10; } sum=sum%1000000007; rem=temp=0; square=sqrt(sum); if(sum==(pow(square,2))) squares_of_sum+=i; sum=square=0; }

    printf("%lu",abs(squares_of_sum));
    

    }