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.
(In reply to
re: computer solution by Larry)
Thanks. The idea goes back to when there were such things as "use four 4's to make a particular number", or "as many numbers as you can". I had always produced RPN (reverse polish notation) and sometimes converted to algebraic notation, but with poor results, having an excess of parentheses.
Keeping track of the algebraic notation while still in the stack enables selective placement of parentheses, but it's facilitated by Matlab's handling of strings, especially the eval function which can treat stings as if the contents were code. For one thing, it handled precedence almost by itself--I only had to think about if for the parentheses. It required getting out of the Basic language mindset.
Edited on April 19, 2025, 7:35 am
|
Posted by Charlie
on 2025-04-19 07:33:00 |