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

Home > Numbers
Conjoined Twins (Posted on 2023-10-20) Difficulty: 3 of 5
Determine the smallest pair of twin primes A and B, such that when concatenated, A and B will contain all 10 decimal digits.

See The Solution Submitted by K Sengupta    
Rating: 5.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Analytically assisted computer solution | Comment 1 of 3
Call the final two digits of the smaller prime "y" and "z":
    option one - if z is (1,3,5,7}, the smallest possible number is a 9-digit number which does not include z+2
    option two - if z is 9, there could be an 8-digit number which does not include y+1 or 1, since adding 2 will convert ......y9 into .....(y+1)1

limit the initial search to 8-digit numbers ending in 9 and which contain neither 1 or the penultimate digit plus one.

The program ran less than one second.
(20487359, 20487361)

--------------------
def isprime(n):
    '''check if integer n is a prime'''
    n = abs(int(n))
    if n < 2:
        return False
    if n == 2:
        return True    
    if not n & 1:
        return False
    for x in range(3, int(n**0.5)+1, 2):
        if n % x == 0:
            return False
    return True

for i in range(10000009,100000000,10):
    s = str(i)
    if '1' in s:
        continue
    if len(set(s)) != 8:
        continue
    if str(int(s[6])+1) in s:
        continue
    if isprime(i) and isprime(i+2):
        print('({}, {})'.format(i, i+2))
        break

  Posted by Larry on 2023-10-20 11:59:44
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (1)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (13)
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