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

Home > Numbers
Deux Duodecimal Prime Number Determination. (Posted on 2023-03-24) Difficulty: 3 of 5
N is a 5-digit duodecimal prime number which consists of precisely two distinct nonzero base-12 digits.

Determine the smallest and largest value of N.

*** N cannot admit of any leading zeros.

See The Solution Submitted by K Sengupta    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Computer solution Comment 2 of 2 |
If the problem is interpreted as precisely two distinct nonzero base-12 digits and only nonzero digits are allowed, then:
There are 171 such 5-digit duodecimal primes
Smallest:  11151 which is 22669 in base 10
Largest:   BBBB7 which is 248827 in base 10

In what is probably a bizarre coincidence, if you eliminate the constraint of the digits all being nonzero, then instead of 171 solutions, you get 172; and the sole solution containing zeros is 10011 which is then the smallest.


If the problem is interpreted as precisely two distinct nonzero base-12 digits but in addition to those nonzero digits, some zero digits are allowed, (although I do not believe this is the intended interpretation) then:
There are 554 such 5-digit duodecimal primes
Smallest:  10007 which is 20743 in base 10
Largest:   BBBB7 which is 248827 in base 10

----------
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

def base2base(n,a,b):
    """ input n which is a string of the number to be changed
    'a' is an integer representing the current base
    to be changed to base b
    """
    def dec2base(i,base):
        """ INPUT integer in base 10, return string
        of Base base equivalent. """
        convertString = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
        if i < base:
            return convertString[i]
        else:
            return dec2base(i//base,base) + convertString[i%base]
    if a == 10:
        return dec2base(int(n),b)
    if b == 10:
        return int(str(n),a)
    elif b != 10:
        return base2base(int(str(n),a),10,b)


lo = base2base('10000',12,10)
hi = base2base('BBBBB',12,10)
zerosAllowed = True
count = 0
count0 = 0
ans = []
answithzeros = []
for zerosAllowed in [True,False]:
    for n in range(lo,hi):
        if not isprime(n):
            continue
        
        n12 = base2base(n,10,12)
        if not zerosAllowed:
            if '0' in n12:
                continue
            if len(set(n12)) != 2:
                continue
            ans.append(n12)
            count += 1
            print(n12)
        else:
            if '0' in n12:
                if len(set(n12)) != 3:
                    continue
            elif '0' not in n12:
                if len(set(n12)) != 2:
                    continue
            answithzeros.append(n12)
            count0 += 1
            print(n12)

print('no zeros',count)
print('zeros allowed',count0)



  Posted by Larry on 2023-03-24 09:25:45
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