Sum of Two Squares

08172019, 01:35 PM
Post: #1




Sum of Two Squares
Given a positive integer n, can we find two nonnegative integers x and y such that:
n = x^2 + y^2 The program presented here is the use of iterations to find all possible pairs which fit n = x^2 + y^2. Some integers do not have representations, others have more than one. The program will show all possible combinations. HP Prime Program SUM2SQ Code:
Blog link: http://edspi31415.blogspot.com/2019/08/h...ftwo.html 

08172019, 07:05 PM
Post: #2




RE: Sum of Two Squares
Very interesting :)
Another interesting topic in number theroy is Bézout's_identity https://en.wikipedia.org/wiki/Bézout's_identity Can you write a program for this also? 

08182019, 05:27 PM
Post: #3




RE: Sum of Two Squares
I'll check it out and maybe give it a shot.


08202019, 05:25 AM
Post: #4




RE: Sum of Two Squares
(08172019 07:05 PM)klesl Wrote: Very interesting :) Here is the Bezout program: this program returns the gcd of two integers a and b, and all of the possible integer solutions that fit a*x + b*y = d, with in a given range [m, m]: Code: EXPORT BEZOUT(a,b,m) Output: { gcd, list of (x,y) pairs } Example: a = 18, b = 45, m = 20, find all solutions within the range [20, 20]: BEZOUT(18, 45, 20): {9, {(17, 7), (12,5), (7,3), (2,1), (3,1), (8,3), (13,5), (18,7)}} 

« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)