For all three parts, consider integers with all of the following properties:
- the SOD(n^2) is also a square
- the SOD(n^3) is also a cube
- the SOD(n^4) is also a fourth power
- n is NOT a power of 10
Please find A, B, and C where:
(Part 1) A is the smallest such integer.
(Part 2) B is the smallest such integer whose first digit is different than the first digit of A.
(Part 3) C is the smallest such integer whose first digit is different than the first digit of A or B.
** SOD(n) is the Sum Of Digits of n
The answers:
1. 11 (see line 2 of the below output)
2. 3138 (see the next-to-last line of the first table below; the last line, for 3558, also begins with a 3)
3. 625008 (from the last line of the second table -- output from second program)
for n=2:floor(999999999999999^(1/4))
c=char(string(n));
sq=n*n;
s=sod(sq);
sr=round(sqrt(s));
if sr*sr==s
cu=n^3;
s=sod(cu);
cr=round(s^(1/3));
if cr^3==s
fp=n^4;
s=sod(fp);
fr=round(s^(1/4));
if fr^4==s
fprintf('%15d',n, sq, sod(sq), cu, sod(cu), fp, s)
fprintf('\n')
end
end
end
end
10 100 1 1000 1 10000 1
11 121 4 1331 8 14641 16
100 10000 1 1000000 1 100000000 1
101 10201 4 1030301 8 104060401 16
110 12100 4 1331000 8 146410000 16
1000 1000000 1 1000000000 1 1000000000000 1
1001 1002001 4 1003003001 8 1004006004001 16
1010 1020100 4 1030301000 8 1040604010000 16
1100 1210000 4 1331000000 8 1464100000000 16
3138 9847044 36 30900024072 27 96964275537936 81
3558 12659364 36 45042017112 27 160259496884496 81
(columns adjusted manually).
A separate version, using extended precision, was needed to handle the fourth powers of larger n values. It starts searching with the evaluation of floor(999999999999999^(1/4)), where the other program left off:
for n0=5623:999999
n=vpa(n0);
c=char(string(n));
sq=floor(n*n);
s=sod(sq);
sr=round(sqrt(s));
if sr*sr==s
cu=round(n^3);
s=sod(cu);
cr=round(s^(1/3));
if cr^3==s
fp=round(n^4);
s=sod(fp);
fr=round(s^(1/4));
if fr^4==s
fprintf('%25s',n, sq, sod(sq), cu, sod(cu), fp, s)
fprintf('\n')
end
end
end
end
function s=sod(n)
ns=char(n);
s=sum(ns-48);
end
The format in the fprintf function was not appropriate for the sod's but the squares, cubes and fourth powers show up correctly, so I deleted those columns; it was not enough of value except for the last row, to make worthwhile a rerun of the program again:
10000 100000000 1000000000000 10000000000000000
10001 100020001 1000300030001 10004000600040001
10010 100200100 1003003001000 10040060040010000
10100 102010000 1030301000000 10406040100000000
11000 121000000 1331000000000 14641000000000000
12606 158911236 2003235041016 25252780927047696
15471 239351841 3703012332111 57289303790089281
31380 984704400 30900024072000 969642755379360000
31752 1008189504 32012033131008 1016446075975766016
35580 1265936400 45042017112000 1602594968844960000
100000 10000000000 1000000000000000 100000000000000000000
100001 10000200001 1000030000300001 100004000060000400001
100010 10002000100 1000300030001000 100040006000400010000
100100 10020010000 1003003001000000 100400600400100000000
101000 10201000000 1030301000000000 104060401000000000000
110000 12100000000 1331000000000000 146410000000000000000
126060 15891123600 2003235041016000 252527809270476960000
154710 23935184100 3703012332111000 572893037900892810000
313800 98470440000 30900024072000000 9696427553793600000000
317520 100818950400 32012033131008000 10164460759757660160000
355800 126593640000 45042017112000000 16025949688449600000000
625008 390635000064 244150000120000512 152595703275001280004096
The last line is the only one we really care about, as its n starts with a novel digit, 6.
I've added the sums of the digits to this one line:
square cube fourth power
625008 390635000064 36 244150000120000512 27 152595703275001280004096 81
|
Posted by Charlie
on 2022-07-07 11:23:51 |