# Solve Math Problem Using Python. HALP PLS

 Shivam Misra · August 19, 2015 So i was given this math problem:I am pretty much stumped. So far I have made a very basic code for finding if a number is a square number or not, but I'm not sure how to continue. How do I come about this?

## Replies

 wernich wilsenach · August 20, 2015 i'd go on that exact formula: calculate a2 + b2 , then see if you can get an int from the square root.start with two variables ("a" and "b" if you like) and then see if the two added together are a perfect square. you could do a nested loop so that you can compare 1 and 1, then 1 and 2, then 1 and 3... upto the max you should check, then check 2 and 1, then 2 and 2, then 2 and 3... and so on. when you get a perfect square for "c", then you print those values out. doing it that way should get you the right answers, but you're very likely to get duplicates. get the right answers first, then sort out the duplicates. Otto Von Chesterfield · August 20, 2015 ``from math import sqrtdef findC(a, b): return sqrt(a**2 + b**2)``
• 1

## Python

126,348 followers