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

Home > Probability
Pairs of primes (Posted on 2019-07-27) Difficulty: 4 of 5
Imagine a bag containing cards representing all n-digit odd numbers. A random card is drawn and two new numbers are created by preceding the drawn number by each of its even neighbors.

What is the probability that each of those 2 numbers is prime?

Examples:
For n=1 there are 5 cards i.e. 1,3,5,7 and 9. Clearly only numbers 3 and 9 qualifiy since fboth 23 and 43 are primes and so are 89 and 109 & there are no other answers. So for n=1 p=0.4 is the probability we were looking for.
For n=2 I will not provide the answer but will show you one of the qualifying numbers e.g. 69, since both 6869 and 7069 are prime.

Now evaluate the correct probabilities for n=2,3, ...8,9 (or as far as your resources allow) - and you will get a sequence for which you may be credited @ OEIS.

So this time you get a task both challenging and rewarding!
GOOD LUCK...

No Solution Yet Submitted by Ady TZIDON    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
via computer - the start of the soln | Comment 1 of 10

(Program was corrected for bug noticed by Charlie.)



 dig prob

-----------

 1  0.5000

 2  0.0455

 3  0.0334

 4  0.0124

 5  0.0089

 6  0.0050

  


To get more would require downloading a many Gbyte file of known primes, which seems (sorry - no insult intended) like a bit of a fool's errand...


        program prr

        use iso_fortran_env

        implicit none

        real rat

        integer(kind=int64)::i,j,k,l,twop,odds,b1,b2,k1,k2,flag


           do i = 1,13

           twop=0

           odds=0

           b1=10**(i-1)+1

           if (i.eq.1)b1=1

           b2=10**i-1

                do j = b1,b2,2  

                odds=odds+1

                k1=j+(j-1)*10**i

                k2=j+(j+1)*10**i

                call isprime(k1,flag)

                   if (flag.eq.1)then

                   call isprime(k2,flag)

                   if(flag.eq.1)twop=twop+1

                   endif

                enddo

           rat=1.*twop/(1.*odds)

           print 1,i,rat

1          format(i2,2x,f6.4)

           enddo

        end


        subroutine isprime(i,n) 

        use iso_fortran_env     

        implicit none

        integer (kind=int64)::i,j,k,l,m,n

        n=1

        if(i.eq.2)return

        n=0

        k=sqrt(1.*i)

           do j=2,k

           m=i/j

           l=m*j

           if(l.eq.i)go to 1

           enddo

           n=1

1       return

        end



Edited on July 30, 2019, 5:03 pm
  Posted by Steven Lord on 2019-07-27 13:16:57

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 (0)
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