(41C) Sum of Two Squares - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Software Libraries (/forum-10.html) +--- Forum: General Software Library (/forum-13.html) +--- Thread: (41C) Sum of Two Squares (/thread-13469.html) |
(41C) Sum of Two Squares - Eddie W. Shore - 08-17-2019 01:38 PM Given a positive integer n, can we find two non-negative integers x and y such that: n = x^2 + y^2 (x and y can be 0, n is assumed to be greater than 0) 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. Registers used: R00 = n R01 = counter R02 = temporary Code:
Examples Example 1: n = 325 325 = 1^2 + 18^2 325 = 6^2 + 17^2 325 = 10^2 + 15^2 Example 2: n = 530 530 = 1^2 + 23^2 530 = 13^2 + 19^2 Blog link: http://edspi31415.blogspot.com/2019/08/hp-prime-and-hp-41cdm-41l-sum-of-two.html |