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

Home > Numbers
The LSD of Prime Numbers (Posted on 2015-02-08) Difficulty: 3 of 5
The LSD's (least significant digits) of all prime numbers, other than the special cases of primes 2 and 5, come from just four digits: 1, 3, 7, or 9.

Which of these LSD's occurs most frequently amongst primes less than 10000?

No Solution Yet Submitted by Danish Ahmed Khan    
No Rating

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

Private Sub Form_Load()
 Text1.Text = ""
 crlf$ = Chr(13) + Chr(10)
 Form1.Visible = True
 
 For i = 1 To 10000
  p = prm(i)
  If p > 10000 Then Exit For
  d = p Mod 10
  ct(d) = ct(d) + 1
 Next
 
  Text1.Text = Text1.Text & i - 1 & Str(prm(i - 1)) & crlf
  For j = 1 To 9
    Text1.Text = Text1.Text & Str(ct(j))
  Next
  Text1.Text = Text1.Text & crlf
  
End Sub

Function prm(i)
  Dim p As Long
  Open "17-bit primes.bin" For Random As #111 Len = 4
  Get #111, i, p
  prm = p
  Close 111
End Function

reports (with my annotations):

largest prime in range: prime(1229) = 9973

counts by last digit:
  1  2  3  4 5 6  7  8  9
 306 1 310 0 1 0 308 0 303
 
The numbers do add up to 1229 as 2 and 5 were included. 
 
 


  Posted by Charlie on 2015-02-08 16:15:06
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 (7)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

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