begin background
For any positive integer n, define d(n) to be n plus the sum of the digits of n.
For example, d(79) = 79 + 7 + 9 = 95.
Take integer n as a starting point, you can construct the infinite increasing sequence of integers n, d(n), d(d(n)), d(d(d(n))), ....etc
For example, if you start with 33, the next number is 33 + 3 + 3 = 39, the next
is 39 + 3 + 9 = 51, the next is 51 + 5 + 1 = 57, and so you generate the sequence :
33, 39, 51, 57, 69, 84, 96, 111, 114, 120, 123, 129, 141, ...
The number n is called a generator of d(n). In the sequence above, 33 is a generator of 39, 39 is a generator of 51, 51 is a generator of 57, and so on. Some numbers have more than one generator: for example, 101 has two generators, 91 and 100.
A number with no generators is a self-number.
There are thirteen self-numbers less than 100: 1, 3, 5, 7, 9, 20, 31, 42, 53, 64, 75, 86, and 97.
end background
Now come my questions:
a.(d2) What is the smallest n making a 10n a self number?
b.(d4) Checking integers with 1 in the beginning, 1 in the end and n-1 zeros between the ones (i.e.10n+1) what value of n creates a number with 3 generators ?
c.(d5 or d4 after a hint) What is the smallest number with 4 generators ?
Part a:
Since 1 is a self number, n=0 is the smallest n making 10^n a self number.
For parts b and c, a program output:
Part b:
1 1
2 2
3 2
4 2
5 2
6 2
7 2
8 2
9 2
10 2
11 1
12 2
13 3
10000000000000
9999999999901
9999999999892
14 2
15 1
10^13 + 1 has the three generators shown, being 10^13, 10^13-99 and 10^13-108.
Part c:
done
So no answers were found for part c. It would seem that some such number exists along the lines of 10^13+1, but with a much higher power of 10, outside of the searchable area; but even if we found the appropriate power there'd be no guarantee that a smaller value wouldn't work that doesn't fit the pattern of 10^n+1, unless a proof were offered that multiple-generator numbers must fit that form.
DefDbl A-Z
Dim crlf$
Private Sub Form_Load()
Form1.Visible = True
Text1.Text = ""
crlf = Chr(13) + Chr(10)
Text1.Text = Text1.Text & "Part b:" & crlf
p10 = 10
For n = 1 To 15
self = p10 + 1
noGen = 0
For gen = p10 To p10 - 10 * n Step -1
If gen + sod(gen) = self Then noGen = noGen + 1
Next
Text1.Text = Text1.Text & n & Str(noGen) & crlf
If noGen = 3 Then
For gen = p10 To p10 - 10 * n Step -1
If gen + sod(gen) = self Then Text1.Text = Text1.Text & " " & Str(gen) & crlf
Next
End If
p10 = 10 * p10
Next
Text1.Text = Text1.Text & crlf & "Part c:"
l10 = Log(10)
For n = 1 To 10000000
noGen = 0
For gen = n - 1 To n - 10 * Log(n) / l10 Step -1
DoEvents
If gen + sod(gen) = n Then noGen = noGen + 1
Next
If noGen > 3 Then Text1.Text = Text1.Text & n & Str(noGen) & crlf
Next
Text1.Text = Text1.Text & crlf & " done"
End Sub
Function sod(n)
s$ = LTrim(Str(n))
tot = 0
For i = 1 To Len(s$)
tot = tot + Val(Mid(s$, i, 1))
Next
sod = tot
End Function
|
Posted by Charlie
on 2018-05-23 13:47:34 |