finding the sum of two squares

we were given an exercise about finding the sum of two sqaures. i've been having a hard time doing it. i know that the equation for getting the sum of two sqaures is p = x^2 + y^2, but my problem is that how to make a source code for this. i cant seem to find a way to divide the input number into two perfect squares. i've tried dividing it using the number%4, this results to one which is a perfect square and dividing again the number by number%2. so it looks like this, say the input is 5, 5%4 = 1 and 5%2 = 1... although 1 is a perfect sqaure, however, this is wrong. the correct answer should be 5 = 4 + 1. four and one being perfect sqaures. i need to find a code for this. or at least someone explain to me what i can do so that i can make a source code.thanks
Are you sure you're understanding the problem correctly?

There is no solution for every number. 6, for example, has no solution to this problem, as it can't be broken into two perfect squares.

The original wording suggests that you are should be looking for the sum and not the square roots. In which case you should be getting two numbers from the user (say, 3 and 5), squaring them, then adding them together (so the result would be 36).

I'm guessing that's what you're supposed to be doing. Double-check the wording of the original problem and see if that's the case.
Topic archived. No new replies allowed.