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

Home > Numbers
Sum of subfactorials (Posted on 2018-02-25) Difficulty: 3 of 5
What is the only number equal to the sum of subfactorials of its digits?

Hint: it is below 150000

This fact was discovered by Malachy in 1979.

See The Solution Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 1 of 2
The subfactorials of single digits are:

0   1
1   0
2   1
3   2
4   9
5   44
6   265
7   1854
8   14833
9   133496

The desired answer:

148349 148349

shown as the number itself and the sum of the subfactorials of its digits.

found by

DefDbl A-Z
Dim crlf$, subfact As Variant


Private Sub Form_Load()
 Form1.Visible = True
 
 
 Text1.Text = ""
 crlf = Chr$(13) + Chr$(10)
 
 subfact = Array(1, 0, 1, 2, 9, 44, 265, 1854, 14833, 133496)
 For i = 0 To 9
   Text1.Text = Text1.Text & i & "   " & subfact(i) & crlf
 Next
 
 For n = 1 To 150000
   ns$ = LTrim(Str(n))
   tot = 0
   For i = 1 To Len(ns)
      tot = tot + subfact(Val(Mid(ns, i, 1)))
   Next
   If tot = n Then Text1.Text = Text1.Text & crlf & n & Str(tot) & crlf
 Next
 
 
 Text1.Text = Text1.Text & crlf & " done"
  
End Sub

Edited on February 25, 2018, 11:54 am
  Posted by Charlie on 2018-02-25 11:54:05

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


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

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