What is the biggest even number N that can't be written as a sum of odd composite numbers?
Bonus: Find another feature unique to N.
The program used the first 25 odd composite numbers:
9 15 21 25 27 33 35 39 45 49 51 55 57 63 65 69 75 77 81 85 87 91 93 95 99
and initially attempted to form even numbers up to 1000. The last even number it could not form was 38, and that's the answer.
Only the first 300 were rerun to show how the numbers were formed. Rather than list duplicates of the same odd addend, a coefficient shows how many of that term are used, such as 18 = 2*9 rather than 18 = 9 + 9:
4
6
8
10
12
14
16
18 = 2*9
20
22
24 = 9 + 15
26
28
30 = 9 + 21
32
34 = 9 + 25
36 = 9 + 27
38
40 = 15 + 25
42 = 9 + 33
44 = 9 + 35
46 = 21 + 25
48 = 9 + 39
50 = 15 + 35
52 = 25 + 27
54 = 9 + 45
56 = 21 + 35
58 = 9 + 49
60 = 9 + 51
62 = 27 + 35
64 = 9 + 55
66 = 9 + 57
68 = 33 + 35
70 = 15 + 55
72 = 9 + 63
74 = 9 + 65
76 = 21 + 55
78 = 9 + 69
80 = 15 + 65
82 = 25 + 57
84 = 9 + 75
86 = 9 + 77
88 = 25 + 63
90 = 9 + 81
92 = 15 + 77
94 = 9 + 85
96 = 9 + 87
98 = 21 + 77
100 = 9 + 91
102 = 9 + 93
104 = 9 + 95
106 = 15 + 91
108 = 9 + 99
110 = 15 + 95
112 = 21 + 91
114 = 15 + 99
116 = 21 + 95
118 = 25 + 93
120 = 21 + 99
122 = 27 + 95
124 = 25 + 99
126 = 27 + 99
128 = 33 + 95
130 = 35 + 95
132 = 33 + 99
134 = 35 + 99
136 = 2*9 + 25 + 93
138 = 39 + 99
140 = 45 + 95
142 = 2*9 + 25 + 99
144 = 45 + 99
146 = 51 + 95
148 = 49 + 99
150 = 51 + 99
152 = 2*9 + 35 + 99
154 = 55 + 99
156 = 57 + 99
158 = 9 + 15 + 35 + 99
160 = 9 + 25 + 27 + 99
162 = 63 + 99
164 = 65 + 99
166 = 2*9 + 49 + 99
168 = 69 + 99
170 = 9 + 27 + 35 + 99
172 = 2*9 + 55 + 99
174 = 75 + 99
176 = 77 + 99
178 = 9 + 15 + 55 + 99
180 = 81 + 99
182 = 2*9 + 65 + 99
184 = 85 + 99
186 = 87 + 99
188 = 9 + 15 + 65 + 99
190 = 91 + 99
192 = 93 + 99
194 = 95 + 99
196 = 9 + 25 + 63 + 99
198 = 2*99
200 = 9 + 15 + 77 + 99
202 = 2*9 + 85 + 99
204 = 2*9 + 87 + 99
206 = 9 + 21 + 77 + 99
208 = 2*9 + 91 + 99
210 = 2*9 + 93 + 99
212 = 2*9 + 95 + 99
214 = 9 + 15 + 91 + 99
216 = 2*9 + 2*99
218 = 9 + 15 + 95 + 99
220 = 9 + 21 + 91 + 99
222 = 9 + 15 + 2*99
224 = 9 + 21 + 95 + 99
226 = 9 + 25 + 93 + 99
228 = 9 + 21 + 2*99
230 = 9 + 27 + 95 + 99
232 = 9 + 25 + 2*99
234 = 9 + 27 + 2*99
236 = 9 + 33 + 95 + 99
238 = 15 + 25 + 2*99
240 = 9 + 33 + 2*99
242 = 9 + 35 + 2*99
244 = 21 + 25 + 2*99
246 = 9 + 39 + 2*99
248 = 15 + 35 + 2*99
250 = 25 + 27 + 2*99
252 = 9 + 45 + 2*99
254 = 21 + 35 + 2*99
256 = 9 + 49 + 2*99
258 = 9 + 51 + 2*99
260 = 27 + 35 + 2*99
262 = 9 + 55 + 2*99
264 = 9 + 57 + 2*99
266 = 33 + 35 + 2*99
268 = 15 + 55 + 2*99
270 = 9 + 63 + 2*99
272 = 9 + 65 + 2*99
274 = 21 + 55 + 2*99
276 = 9 + 69 + 2*99
278 = 15 + 65 + 2*99
280 = 25 + 57 + 2*99
282 = 9 + 75 + 2*99
284 = 9 + 77 + 2*99
286 = 25 + 63 + 2*99
288 = 9 + 81 + 2*99
290 = 15 + 77 + 2*99
292 = 9 + 85 + 2*99
294 = 9 + 87 + 2*99
296 = 21 + 77 + 2*99
298 = 9 + 91 + 2*99
300 = 9 + 93 + 2*99
To find out the other unique feature, I consulted Derrick Niederman's book, Number Freak: From 1 to 200, the Hidden Language of Numbers Revealed.
- Under 38 we find it can be written as the sum of two odd numbers in ten different ways. Each way includes at least one prime.
- It also confirms the answer that it is indeed the largest even number that cannot be written as the sum of two composite odd numbers. From the current puzzle and its solution, 38 cannot be written as the sum of any number of odd composite numbers, even if more than two such addends were allowed (and higher number could be obtained with just two terms, that I did not bother to get in the above list).
- But 38 when written as Roman numeral XXXVIII is the last Roman numeral alphabetically of all possible Roman numerals.
- It's also the number of slots on an American roulette wheel.
- 38 is also the only possible row sum for a non-trivial magic hexagon of consecutive integers starting at 1.
DefDbl A-Z
Dim crlf$, denom(25), remain, n, facthist(25)
Private Sub Form_Load()
crlf = Chr(13) + Chr(10)
Text1.Text = ""
Form1.Visible = True
n = 9
Do
If prmdiv(n) <> n Then
dct = dct + 1
denom(dct) = n
Text1.Text = Text1.Text & Str(n)
End If
n = n + 2
DoEvents
Loop Until dct = 25
Text1.Text = Text1.Text & crlf & crlf
For n = 4 To 300 Step 2
remain = n
For i = 1 To 25
facthist(i) = 0
Next
addOn 25
If remain > 0 Then Text1.Text = Text1.Text & Str(n) & crlf
If remain = 0 Then
Text1.Text = Text1.Text & n & " = "
For i = 1 To 25
If facthist(i) > 0 Then
Text1.Text = Text1.Text & " + " & facthist(i) & "*" & denom(i)
End If
Next
Text1.Text = Text1.Text & crlf
End If
Next
Text1.Text = Text1.Text & crlf & " done"
End Sub
Sub addOn(wh)
DoEvents
If remain = 0 Then Exit Sub
q = Int(remain / denom(wh))
For i = q To 0 Step -1
saveRemain = remain
remain = remain - i * denom(wh)
facthist(wh) = i
If remain = 0 Then
Exit For
End If
If wh > 1 Then
addOn wh - 1
If remain = 0 Then Exit For
End If
remain = saveRemain
Next i
End Sub
Function prmdiv(num)
Dim n, dv, q
If num = 1 Then prmdiv = 1: Exit Function
n = Abs(num): If n > 0 Then limit = Sqr(n) Else limit = 0
If limit <> Int(limit) Then limit = Int(limit + 1)
dv = 2: GoSub DivideIt
dv = 3: GoSub DivideIt
dv = 5: GoSub DivideIt
dv = 7
Do Until dv > limit
GoSub DivideIt: dv = dv + 4 '11
GoSub DivideIt: dv = dv + 2 '13
GoSub DivideIt: dv = dv + 4 '17
GoSub DivideIt: dv = dv + 2 '19
GoSub DivideIt: dv = dv + 4 '23
GoSub DivideIt: dv = dv + 6 '29
GoSub DivideIt: dv = dv + 2 '31
GoSub DivideIt: dv = dv + 6 '37
Loop
If n > 1 Then prmdiv = n
Exit Function
DivideIt:
Do
q = Int(n / dv)
If q * dv = n And n > 0 Then
prmdiv = dv: Exit Function
Else
Exit Do
End If
Loop
Return
End Function
|
Posted by Charlie
on 2018-07-29 13:06:40 |