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

 Why Haydn ? (Posted on 2014-05-21)
WHY is the largest prime factor of HAYDN.

 See The Solution Submitted by Ady TZIDON No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
 computer solution | Comment 1 of 2
DefDbl A-Z
Dim   crlf\$

Text1.Text = ""
crlf\$ = Chr(13) + Chr(10)
Form1.Visible = True
For n = 12345 To 98765
ns\$ = LTrim(Str(n))
good = 1
For i = 1 To 4
If InStr(Mid(ns\$, i + 1), Mid(ns\$, i, 1)) > 0 Then good = 0
Next
If good Then
pf = n
While prmdiv(pf) > 1 And prmdiv(pf) < pf
pf = pf / prmdiv(pf)
Wend
If pf > 99 And pf < 1000 Then
pfs\$ = LTrim(Str(pf))
If Mid(pfs\$, 2, 1) = Mid(ns\$, 1, 1) And Mid(pfs\$, 3, 1) = Mid(ns\$, 3, 1) Then
If InStr(ns\$, Mid(pfs\$, 1, 1)) = 0 Then
Text1.Text = Text1.Text & Str(pf) & Str(n) & "     "
n2 = n
p = prmdiv(n2): n2 = n2 / p
While p > 1
Text1.Text = Text1.Text & Str(p)
p = prmdiv(n2): n2 = n2 / p
Wend
Text1.Text = Text1.Text & crlf
End If
End If
End If
End If
Next n
Text1.Text = Text1.Text & "----------------" & crlf

' the following is for a similar puzzle: WHY is smallest prime factor of HAYDN.

For n = 12345 To 98765
ns\$ = LTrim(Str(n))
good = 1
For i = 1 To 4
If InStr(Mid(ns\$, i + 1), Mid(ns\$, i, 1)) > 0 Then good = 0
Next
If good Then
pf = prmdiv(n)
If pf > 99 And pf < 1000 Then
pfs\$ = LTrim(Str(pf))
If Mid(pfs\$, 2, 1) = Mid(ns\$, 1, 1) And Mid(pfs\$, 3, 1) = Mid(ns\$, 3, 1) Then
If InStr(ns\$, Mid(pfs\$, 1, 1)) = 0 Then
Text1.Text = Text1.Text & Str(pf) & Str(n) & "          "
n2 = n
p = prmdiv(n2): n2 = n2 / p
While p > 1
Text1.Text = Text1.Text & Str(p)
p = prmdiv(n2): n2 = n2 / p
Wend
Text1.Text = Text1.Text & crlf
End If
End If
End If
End If
Next n

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

finds the following solutions to the puzzle:

` WHY HAYDN    Prime factors of HAYDN 613 18390      2 3 5 613 523 20397      3 13 523 127 23749      11 17 127 127 24765      3 5 13 127 521 28134      2 3 3 3 521 521 29176      2 2 2 7 521 137 34798      2 127 137 739 36950      2 5 5 739 139 36974      2 7 19 139 139 38920      2 2 2 5 7 139 239 38957      163 239 947 40721      43 947 149 40975      5 5 11 149 541 42198      2 3 13 541 743 42351      3 19 743 547 43760      2 2 2 2 5 547 941 45168      2 2 2 2 3 941 149 46935      3 3 5 7 149 853 50327      59 853 359 50978      2 71 359 953 54321      3 19 953 359 54927      3 3 17 359 859 54976      2 2 2 2 2 2 859 461 63157      137 461 163 64385      5 79 163 863 67314      2 3 13 863 461 69150      2 3 5 5 461 271 70189      7 37 271 173 74390      2 5 43 173 173 78369      3 151 173 389 80912      2 2 2 2 13 389 487 82790      2 5 17 487 281 83176      2 2 2 37 281 281 85143      3 101 281 487 85712      2 2 2 2 11 487 283 86315      5 61 283 389 87914      2 113 389 193 90324      2 2 3 3 13 193 193 95342      2 13 19 193 197 95742      2 3 3 3 3 3 197`

It then finds the solution to a similar puzzle: if WHY is the smallest prime factor of HAYDN. It has only two solutions:

` 157 54793           157 349 193 96307           193 499`

 Posted by Charlie on 2014-05-21 16:19:59

 Search: Search body:
Forums (0)