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

 Prime phone (Posted on 2018-09-28)
What is the largest possible telephone number in the U.S,
that is a prime number?

 No Solution Yet Submitted by Ady TZIDON No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
 computer solution Comment 1 of 1
U.S. telephone numbers, including the NPA (area code), contain 10 digits.

The largest area code in the U.S. is 989, which is in Michigan. This part is called the NPA, the second digit of which cannot currently be a 9; in the future, when the current system becomes inadequate, use of a 9 in this position may be allowed. Next is the NXX. This can be as high as 999. The remaining four digits can be as high as 9999.

see:

The largest prime meeting the criteria, formatted as a phone number, is 989-999-9987.

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

Text1.Text = ""
crlf\$ = Chr(13) + Chr(10)
Form1.Visible = True

p = 9899999999#
Text1.Text = prvprm(p) & crlf

Text1.Text = Text1.Text & "done"

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 prvprm(x)
Dim n
n = x
While prmdiv(n) < n Or n < 2
n = n - 2
DoEvents
Wend
prvprm = n
End Function

 Posted by Charlie on 2018-09-28 10:56:13

 Search: Search body:
Forums (0)