Re: Friedman Number
- To: mathgroup at smc.vnet.net
- Subject: [mg71613] Re: Friedman Number
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Sat, 25 Nov 2006 05:36:50 -0500 (EST)
- Organization: The Open University, Milton Keynes, UK
- References: <ejuqp4$i10$1@smc.vnet.net>
zeta wrote:
> Hi,
>
> How progamming Friedman Number in Mathematica-Code
>
>
> Many Thanks
> Zeta
>
[ Note: This is the 2nd attempt to post this reply to Mathgroup. ]
I followed the algorithm [1] for b == 10 and 2-digit numbers. I leave it
to you to clean the code, catch some possible division by zero, and to
extend the program to 3-digit numbers and above.
In[1]:=
values = Range[-1, 10];
pairs = DeleteCases[Flatten[Outer[List, values,
values], 1], {0, _}];
possibles = Select[pairs,
10*#1[[1]] + #1[[2]] == #1[[1]]*#1[[2]] ||
10*#1[[1]] + #1[[2]] == #1[[1]]^#1[[2]] ||
10*#1[[1]] + #1[[2]] == #1[[2]]^#1[[1]] & ];
Cases[possibles, {_?Positive, x_ /; x >= 0}];
ToExpression /@ StringJoin /@ Map[ToString, %, {-1}]
Out[5]=
{25}
Regards,
Jean-Marc
1. http://en.wikipedia.org/wiki/Friedman_number