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

Home > Just Math
Primes in arithmetic progression (Posted on 2008-09-30) Difficulty: 3 of 5
Ten primes, each less than 3000, form an arithmetic progression. Find them.

See The Solution Submitted by pcbouhid    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 1 of 9
   10   repeat
   20     N=nxtprm(N):Ct=Ct+1
   30   until N>3000
   40   NoPrimes=Ct-1
   50   for Sub1=1 to NoPrimes-9
   60   for Sub2=NoPrimes to Sub1+9 step -1
   70     if (prm(Sub2)-prm(Sub1))@9=0 then
   80      :Good=1
   90      :Increm=int((prm(Sub2)-prm(Sub1))/9)
  100      :for I=1 to 8
  110        :if prmdiv(prm(Sub1)+I*Increm)<prm(Sub1)+I*Increm then Good=0:endif
  120      :next
  130      :if Good then
  140        :for I=0 to 9
  150          :print prm(Sub1)+I*Increm;
  151          :P=prm(Sub1)+I*Increm
  152          :for J=1 to NoPrimes
  153           :if prm(J)=P then print "(";cutspc(str(J));")":endif
  154          :next
  160        :next
  165        :print:print Increm
  170      :endif
  180   next
  190   next

Finds a sequence starting at 199 in increments of 210:


 199 (46)
 409 (80)
 619 (114)
 829 (145)
 1039 (175)
 1249 (204)
 1459 (232)
 1669 (263)
 1879 (289)
 2089 (316)

The program checks all pairs of primes in the given range and sees if they differ by a multiple of 9.  If so, each intervening 1/9 of the way over is checked for primality. If all of them are prime, the result prints.


  Posted by Charlie on 2008-09-30 13:16:46
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 (3)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

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