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

Home > Numbers
Mean Crossed Reversal Muse (Posted on 2023-03-19) Difficulty: 3 of 5
Determine all possible pairs (p, q) of base ten positive integers that satisfy this system of equations:
  • arithmetic mean (p, q) = 10x+y
  • geometric mean (p, q) = 10y+x
where, each of p and q is a nonzero base ten integer, with p≠q, and each of x and y is a base ten digit.

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 Solution | Comment 1 of 3
(p,q) is either (32,98) or (98,32)
the arithmetic mean is 65
the geometric mean is 56
Not surprisingly, given that there is a theoremm about it:  AM > GM

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

squares = [i*i for i in range(10,100) if not isprime(i)]

for s in squares:
    gm = int(s**.5)
    for i in range(1,gm):
        if (s/i)%1 == 0:
            p = i
            q = int(s/i)
            x = gm%10
            y = gm//10
            if (p+q)/2 == 10*x + y:
                print('(p,q) is either ({},{}) or ({},{})'.format(p,q,q,p))
                print('the arithmetic mean is {}'.format(int((p+q)/2)))
                print('the geometric mean is {}'.format(int((p*q)**.5)))


------    #alternate method, same result
for a in range(1,201):
    for b in range(1,201):
        if a == b:
            continue
        am = (a+b)/2
        if am%1 != 0:
            continue
        if am > 99:
            continue
        gm = (a*b)**.5
        if gm%1 != 0:
            continue
        am = int(am)
        gm = int(gm)
        y = am%10
        x = am//10
        if gm == 10*y  + x:
            print(a,b,am,gm)

Output:
32 98 65 56
98 32 65 56

  Posted by Larry on 2023-03-19 08:36: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 (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