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

Home > Numbers
Prime phone (Posted on 2018-09-28) Difficulty: 2 of 5
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.)
Solution 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

Private Sub Form_Load()
 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
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (4)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2018 by Animus Pactum Consulting. All rights reserved. Privacy Information