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

Home > Numbers
Even and Odd Digit Numbers (Posted on 2023-09-08) Difficulty: 3 of 5
(A) Two different five digit base ten numbers M and N are constituted entirely by even digits.
What is the least value of M+N, given that M*N is a perfect square?

(B) Two different five digit numbers M and N are constituted entirely by odd digits.
What is the least value of M+N, given that M*N is a perfect square?

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 Computer solution | Comment 1 of 2
Algorithm:
    two programs, one for evens, another for odds
    build lists of numbers with all even and all odd digits
    search more efficiently by breaking out of a loop once the current sum is larger than the minimum sum found so far

(A): 20000+20402 = 40402 = 20200^2
(B): 11999+15975= 27974= 13845^2

---------------
Printout of program:
[20000, 20402, 40402, 20200.0]
Answer for evens
[20000, 20402, 40402, 20200.0]


[11111, 99999, 111110, 33333.0]
[11191, 19375, 30566, 14725.0]
[11999, 15975, 27974, 13845.0]
Answer for odds
[11999, 15975, 27974, 13845.0]
---------------
squares = [i*i for i in range(10000, 100000)]

eDigits = []
for a in [2,4,6,8]:
    for b in [0,2,4,6,8]:
        for c in [0,2,4,6,8]:
            for d in [0,2,4,6,8]:
                for e in [0,2,4,6,8]:
                    eDigits.append(10000*a+1000*b+100*c+10*d+e)
oDigits = []
for a in [1,3,5,7,9]:
    for b in [1,3,5,7,9]:
        for c in [1,3,5,7,9]:
            for d in [1,3,5,7,9]:
                for e in [1,3,5,7,9]:
                    oDigits.append(10000*a+1000*b+100*c+10*d+e)


lenEvens = len(eDigits)
lenOdds = len(oDigits)
esolutions = []
osolutions = []
minsum = 10000000
for i in range(lenEvens):
    if eDigits[i] > minsum/2:
        break
    for j in range(i+1, lenEvens):
        thissum = eDigits[i]+eDigits[j]
        if thissum > minsum:
            break
        eprod = eDigits[i]*eDigits[j]
        if eprod in squares:
            if thissum < minsum:
                minsum = thissum
            esolutions.append([eDigits[i],eDigits[j],thissum,(eprod)**.5])
            print([eDigits[i],eDigits[j],thissum,(eprod)**.5])
            break

print('Answer for evens')
for s in esolutions:
    if s[2] == minsum:
        print(s)
print(' ')

minsum = 10000000
for i in range(lenOdds):
    if oDigits[i] > minsum/2:
        break
    for j in range(i+1, lenOdds):
        thissum = oDigits[i]+oDigits[j]
        if thissum > minsum:
            break
        oprod = oDigits[i]*oDigits[j]
        if oprod in squares:
            if thissum < minsum:
                minsum = thissum
            osolutions.append([oDigits[i],oDigits[j],thissum,(oprod)**.5])
            print([oDigits[i],oDigits[j],thissum,(oprod)**.5])
            break

print('Answer for odds')
for s in osolutions:
    if s[2] == minsum:
        print(s)

Edited on September 8, 2023, 8:47 am
  Posted by Larry on 2023-09-08 08:46:11

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