I want to use the power function to make the digits 1234567 to the sum of squared digits. Eg, 1^2+2^2+3^2+4^2+5^2+6^2+7^2=140
I have done:
#include <cmath>
int b;
b = pow((id/1000000),2) + pow(((id%1000000)/100000),2) + pow(((id%100000)/10000),2) + pow(((id%10000)/1000),2) + pow(((id%1000)/100),2) + pow(((id%100)/10),2) + pow((id%10),2);
I get the answer of 2 where it suppose to be 140. What went wrong? Can someone please help me?