I currently want to use the 7 digits: 1234567 to make the sum of squared digits so 1^2+2^2+3^2+4^2+5^2+6^2+7^2=140

I have already done this code as follows:

b = (id/1000000)^2 + ((id%1000000)/100000)^2 +

((id%100000)/10000)^2 + ((id%10000)/1000)^2 +

((id%1000)/100)^2 + ((id%100)/10)^2 + (id%10)^2;

b should equal to 140, but I only get the sum of 2. Can somebody please help me.