my code is satisfying the given testcase in quesn but it is giving the wrong ans after submiting. i dont know what is missing in my code
Pythagorean question
For input -
1
14161
Your answer-
(0, 119) (56, 105) (105, 56)
Expected answer is-
(0,119) (56,105)
Also for input -
3
0
100
25
Your answer-
(0, 10) (6, 8) (8, 6)
(0, 5) (3, 4) (4, 3)
Expected answer-
(0,0)
(0,10) (6,8)
(0,5) (3,4)
Problem statement is pretty clear, We just need to find such pairs who satisfies the pythagoras theorem upto that number.
The idea is to put two nested loops and print those numbers whose squared sum is equal to the given number.
So you can basically use a nested loop inside the while loop ,
for i loop runs from 0,n till i * i<n inside this loop you can use another loop j which runs from i to n till j*j<n
Inside this j loop check for i * i + j * j == n if it is true then print (i,j)
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.