S is the smallest sum of the squares of the first prime numbers that is a palindrome.
What else can be said about S?
There's a trivial case, where the "sum" is only of the first prime itself: 2^2 = 4, which is technically palindromic.
However the sum of the squares of the first seven primes is also palindromic:
pr squ
2 4
3 9
5 25
7 49
11 121
13 169
17 289
---
666 sum of squares
The sum has also come to be called the Number of the Beast from the New Testament book Revelation, or Apocalypse, with various interpretations of what that means. Most commonly it's taken as the Hebrew-alphabet numbering equivalent to the name Nero.
DefDbl A-Z
Dim crlf$
Function mform$(x, t$)
a$ = Format$(x, t$)
If Len(a$) < Len(t$) Then a$ = Space$(Len(t$) - Len(a$)) & a$
mform$ = a$
End Function
Private Sub Form_Load()
Text1.Text = ""
crlf$ = Chr(13) + Chr(10)
Form1.Visible = True
p = 1
Do
p = nxtprm(p)
p2 = p * p
tot = tot + p2
If isPalin(tot) Then
Text1.Text = Text1.Text & p & Str(tot) & crlf
p1 = 1
Do
p1 = nxtprm(p1)
Text1.Text = Text1.Text & p1 & Str(p1 * p1) & crlf
Loop Until p1 = p
End If
DoEvents
Loop
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
Function nxtprm(x)
Dim n
n = x + 1
While prmdiv(n) < n Or n < 2
n = n + 1
Wend
nxtprm = n
End Function
Function isPalin(n)
s$ = LTrim(Str(n))
good = 1
For i = 1 To Len(s$) / 2
If Mid$(s$, i, 1) <> Mid$(s$, Len(s$) + 1 - i, 1) Then good = 0: Exit For
Next
isPalin = good
End Function
|
Posted by Charlie
on 2018-10-07 11:11:39 |