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

Home > Probability
Product Crossed Square Settlement (Posted on 2022-08-19) Difficulty: 3 of 5
N is a 7-digit positive integer whose product of the digits is 20160.

Determine the probability that the sum of the digits of 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 Solution | Comment 1 of 5
Program output:
5 28560 0.00017507002801120448
The required probability is 0.00017507002801120448
The required squares are [1763584, 5184729, 5948721, 7458361, 8317456]
Their square roots are [1328, 2277, 2439, 2731, 2884]

------ code -------
def isSquare(n):
    """ Input an integer, Returns True iff it is a perfect square. """
    if round(n**0.5)**2 == n:
        return True
    else:
        return False
    
def pod(n):
    """ Input an integer.  Returns the Product of the Digits  """
    aList = list(str(n))
    ans = 1
    for c in aList:
        ans = ans * int(c)
    return ans

answers = []
podcount = 0
sqrcount = 0
for i in range(1000000,10000000):
    if pod(i) != 20160:
        continue
    podcount += 1
    if isSquare(i):
        sqrcount += 1
        answers.append(i)

roots = []
for i in answers:
    roots.append(int(i**.5))

print(sqrcount, podcount, sqrcount/podcount)
print('The required probability is', sqrcount/podcount)
print('The required squares are', answers)
print('Their square roots are', roots)

  Posted by Larry on 2022-08-19 06:48:43
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 (11)
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