Python program to enter Positive number N and find numbers a and b such that a2 - b2 = N | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Python program to enter Positive number N and find numbers a and b such that a2 - b2 = N

15th Mar 2018, 5:39 PM
Manorama
Manorama - avatar
4 Answers
+ 13
well there are infinite such possibilities for a , b , N belonging to set of natural numbers & following condition a*2-b*2=N //N must be even if a2 denotes a^2 ... then a^2=b^2+N ... run a loop for b & find if b^2+ N is forming some perfect square ... if so then that will be corresponding value of a but that is hard to know what can be the maximum value b can take
15th Mar 2018, 5:43 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 4
a^2-b^2=(a-b)*(a+b)=N find some factorization of N
15th Mar 2018, 5:46 PM
michal
+ 1
thanks
15th Mar 2018, 5:57 PM
Manorama
Manorama - avatar
0
hello
15th Mar 2018, 5:52 PM
Jokeriiii
Jokeriiii - avatar