All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Numbers
Reverso (Posted on 2014-02-27) Difficulty: 3 of 5
Let f(n) denote the largest prime factor of n which is not a palindrome.

Find all the numbers n (below 20000) such that the sum of the factorials of the digits of n is equal to f(n) reversed.

Example: 2105 = 5*421 and 2!+1!+0!+5! = 124.

No Solution Yet Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution Comment 2 of 2 |

 10    for N=2 to 20000
 20      Ffor=cutspc(str(fnF(N)))
 30      Frev=""
 40      for I=1 to len(Ffor)
 50        Frev=mid(Ffor,I,1)+Frev
 60      next I
 70      Nfor=cutspc(str(N)):Tot=0
 80      for I=1 to len(Nfor)
 90        Tot=Tot+!(val(mid(Nfor,I,1)))
100      next I
110      if Tot=val(Frev) then print N,Ffor,Frev,Tot
120          :gosub *Listpf:gosub *Listfacts:print:inc Solct
130    next
140    print Solct
150    end
160
170
180    fnF(N)
190    local Tr,Lgfact
200    Tr=N:Lgfact=1
210    while Tr>1
220      Pf=prmdiv(Tr)
230      if fnPalin(Pf)=0 then
240        :if Pf>Lgfact then Lgfact=Pf
250      Tr=Tr//Pf
260    wend
270    return(Lgfact)
280
290    fnPalin(X)
300    local S,I,Good
310    S=cutspc(str(X))
320    Good=1
330    for I=1 to int(len(S)/2)
340       if mid(S,I,1)<>mid(S,len(S)+1-I,1) then Good=0
350    next
360    return(Good)
400    '
410    *Listpf
420    Tr=N:print "      ";
430    while Tr>1
440      Pf=prmdiv(Tr):print Pf;:Tr=Tr//Pf
450    wend:print
460    return
500   '
510    *Listfacts
515    print "      ";
520    for I=1 to len(Nfor):print !(val(mid(Nfor,I,1)));:next
530    print:return

In each of the 12 sets below, the first row has the number, n, f(n), f(n) reversed and the total of the factorials of the digits.

For verification, the second line lists all the prime factors and the third line lists the factorial of each digit in turn.


 143    13      31       31
       11  13
       1  24  6

 541    541     145      145
       541
       120  24  1

 2105   421     124      124
       5  421
       2  1  1  120

 2444   47      74       74
       2  2  13  47
       2  24  24  24

 3431   73      37       37
       47  73
       6  24  6  1

 4144   37      73       73
       2  2  2  2  7  37
       24  1  24  24

 4233   83      38       38
       3  17  83
       24  2  6  6

 4301   23      32       32
       11  17  23
       24  6  1  1

 4440   37      73       73
       2  2  2  3  5  37
       24  24  24  1

 10234  43      34       34
       2  7  17  43
       1  1  2  6  24

 12243  53      35       35
       3  7  11  53
       1  2  2  24  6

 12341  43      34       34
       7  41  43
       1  2  6  24  1

Since these seemed to be concentrated in the beginning of the first 20,000, I thought it might be good to see if there were none beyond; but there are, starting with:

20313  61      16       16
      3  3  37  61
      2  1  6  1  6

22320  31      13       13
      2  2  2  2  3  3  5  31
      2  2  6  2  1

30422  53      35       35
      2  7  41  53
      6  1  24  2  2

34030  83      38       38
      2  5  41  83
      6  24  1  6  1

34144  97      79       79
      2  2  2  2  2  11  97
      6  24  1  24  24

35140  251     152      152
      2  2  5  7  251
      6  120  1  24  1

46003  257     752      752
      179  257
      24  720  1  1  6

52100  521     125      125
      2  2  5  5  521
      120  2  1  1  1

53013  431     134      134
      3  41  431
      120  6  1  1  6
     
102613         137     731      731
      7  107  137
      1  1  2  720  1  6

106312         137     731      731
      2  2  2  97  137
      1  1  720  6  1  2

112413         53      35       35
      3  7  53  101
      1  1  2  24  1  6

113162         137     731      731
      2  7  59  137
      1  1  6  1  720  2

120032         31      13       13
      2  2  2  2  2  11  11  31
      1  2  1  1  6  2

134046         677     776      776
      2  3  3  11  677
      1  6  24  1  24  720

200340         53      35       35
      2  2  3  3  3  5  7  53
      2  1  1  6  24  1

202124         23      32       32
      2  2  13  13  13  23
      2  1  2  1  2  24

203112         31      13       13
      2  2  2  3  3  7  13  31
      2  1  6  1  1  2

210304         53      35       35
      2  2  2  2  2  2  2  31  53
      2  1  1  6  1  24

211203         31      13       13
      3  3  31  757
      2  1  1  2  1  6

211232         41      14       14
      2  2  2  2  2  7  23  41
      2  1  1  2  6  2
     
212004         13      31       31
      2  2  3  3  3  13  151
      2  1  2  1  1  24

212264         157     751      751
      2  2  2  13  13  157
      2  1  2  2  720  24

221030         31      13       13
      2  5  23  31  31
      2  2  1  1  6  1

222224         43      34       34
      2  2  2  2  17  19  43
      2  2  2  2  2  24

230160         137     731      731
      2  2  2  2  3  5  7  137
      2  6  1  1  720  1

230315         631     136      136
      5  73  631
      2  6  1  6  1  120
     
231012         31      13       13
      2  2  3  3  3  3  23  31
      2  6  1  1  1  2

234354         281     182      182
      2  3  139  281
      2  6  24  6  120  24

240212         23      32       32
      2  2  7  23  373
      2  24  1  2  1  2

250404         271     172      172
      2  2  3  7  11  271
      2  120  1  24  1  24

253031         631     136      136
      401  631
      2  120  6  1  6  1

260300         137     731      731
      2  2  5  5  19  137
      2  720  1  6  1  1
     


  Posted by Charlie on 2014-02-27 17:05:19
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (1)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (23)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information