
Home > Numbers
Friedman number (Posted on 2025-04-18) |
|
A Friedman number is a positive integer which can be written in some non-trivial way using its own digits, together with the symbols + – × / ^ ( ) and concatenation. For example, 25 = 5 2 and 126 = 21 × 6. All Friedman numbers with 4 or fewer digits are known:
25, 121, 125, 126, 127, 128, 153, 216, 289, 343, 347, 625, 688, 736, 1022, 1024,
1206, 1255, 1260, 1285, 1296, 1395, 1435, 1503, 1530, 1792, 1827, 2048, 2187, 2349,
2500, 2501, 2502, 2503, 2504, 2505, 2506, 2507, 2508, 2509, 2592, 2737, 2916, 3125,
3159, 3281, 3375, 3378, 3685, 3784, 3864, 3972, 4088, 4096, 4106, 4167, 4536, 4624,
4628, 5120, 5776, 5832, 6144, 6145, 6455, 6880, 7928, 8092, 8192, 9025, 9216, 9261.
Determine why each of these is a Friedman number.
computer solution
|
| Comment 1 of 3
|
clearvars,clc global digset stack found fried ops ops='+-*/^'; frieds=[25, 121, 125, 126, 127, 128, 153, 216, 289, 343, 347, 625, 688, 736, 1022, 1024, ... 1206, 1255, 1260, 1285, 1296, 1395, 1435, 1503, 1530, 1792, 1827, 2048, 2187, 2349, ... 2500, 2501, 2502, 2503, 2504, 2505, 2506, 2507, 2508, 2509, 2592 ,2737, 2916, 3125, ... 3159, 3281, 3375, 3378, 3685, 3784, 3864, 3972, 4088, 4096, 4106, 4167, 4536, 4624, ... 4628, 5120, 5776, 5832, 6144, 6145, 6455, 6880, 7928, 8092, 8192, 9025, 9216, 9261]; for fn=1:length(frieds) digs=uniqueperms(num2str(frieds(fn))); fried=frieds(fn); for p=1:length(digs) digset=digs(p,:); stack=string.empty; found=false; makeVal if found break end end if ~found disp(fried) end end
function makeVal global digset stack found fried ops for choice=1:7 savestack=stack; savedigs=digset; switch choice case {1,2,3,4,5} if length(stack)>=2 if choice==5 if isnan(str2double(stack(2))) stack(2)=strcat("(",stack(2),")"); end if isnan(str2double(stack(1))) stack(1)=strcat("(",stack(1),")"); end else if any(char(stack(2))=='+'|char(stack(2))=='-') stack(2)=strcat("(",stack(2),")"); end if any(char(stack(1))=='+'|char(stack(1))=='-') stack(1)=strcat("(",stack(1),")"); end end stack(1)=string([char(stack(2)) ops(choice ) char(stack(1))]); stack(2)=[]; if isscalar(stack) && isempty(digset) if eval(strcat(stack, "==", string(fried))) % disp([string(fried),stack]) fprintf('%5s %s ',string(fried),stack) found=true; break end else makeVal; if found break end end end case 6 if ~isempty(digset) stack(2:end+1)=stack(1:end); stack(1)=string(digset(1)); digset(1)=[]; makeVal; end case 7 if ~isempty(digset) && ~isempty(stack) if ~isnan(str2double(stack(1))) && stack(1)~="0" stack(1)=strcat(stack(1),digset(1)); digset(1)=[]; makeVal; end end end digset=savedigs; stack=savestack; end end
25 5^2 121 11^2 125 5^(1+2) 126 21*6 127 2^7-1 128 2^(8-1) 153 3*51 216 6^(1+2) 289 (8+9)^2 343 (3+4)^3 347 4+7^3 625 5^(6-2) 688 86*8 736 3^6+7 1022 2^10-2 1024 (2-4)^10 1206 201*6 1255 251*5 1260 210*6 1285 (1+2^8)*5 1296 16*9^2 1395 15*93 1435 35*41 1503 3*501 1530 30*51 1792 (2^(9-1))*7 1827 21*87 2048 ((0+8)^4)/2 2187 (1^8+2)^7 2349 29*3^4 2500 (0+50)^2 2501 1+50^2 2502 2+50^2 2503 3+50^2 2504 4+50^2 2505 50^2+5 2506 50^2+6 2507 50^2+7 2508 50^2+8 2509 50^2+9 2592 2^5*9^2 2737 (2*7)^3-7 2916 (1*6*9)^2 3125 (1*2+3)^5 3159 351*9 3281 (1+3^8)/2 3375 ((3+5)+7)^3 3378 3+((7+8)^3) 3685 (3^6+8)*5 3784 473*8 3864 3*(6^4-8) 3972 3+(7*9)^2 4088 ((0+8)^4)-8 4096 (0*9+4)^6 4106 10+4^6 4167 4^6+71 4536 3^4*56 4624 (4+64)^2 4628 4+68^2 5120 2^10*5 5776 76^(7-5) 5832 (2*5+8)^3 6144 (4^(1+4))*6 6145 1+4^5*6 6455 5*(6^4-5) 6880 80*86 7928 7+89^2 8092 90^2-8 8192 (2^(1+9))*8 9025 (0+95)^2 9216 (1*96)^2 9261 21^(9-6) Edited on April 18, 2025, 2:50 pm
|
Posted by Charlie
on 2025-04-18 14:48:24 |
|
 |
Please log in:
Forums (0)
Newest Problems
Random Problem
FAQ |
About This Site
Site Statistics
New Comments (6)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On
Chatterbox:
|