(11C) Sums of Three 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: (11C) Sums of Three Squares (/thread-12128.html) (11C) Sums of Three Squares - Gamo - 01-07-2019 12:09 PM Which whole numbers are expressible as sums of three (integer) squares? This program solve the Sums of Three Squares. [ X^2 + Y^2 + Z^2 = N ] Given N program will find pair of X,Y and Z that equal to N where X ≤ Y ≤ Z ------------------------------------------------------------------- Procedure: 1.) N [A] display Z [Rv] Y [Rv] X [R/S] if it is more than one solution and continue until steps 2.) shown mean finish. 2.) N [A] display 0.000000000 then 0.00 indicate that "No Solution" ------------------------------------------------------ Example: X^2 + Y^2 + Z^2 = 9876543210 9876543210 [A] display 99380 [Rv] 391 [Rv] 77 [R/S] 99380 [Rv] 359 [Rv] 173 [R/S] "0.000000000" 0.00 Answer: X=77 Y=391 Z=99380 X=173 Y=359 Z=99380 ---------------------------------------------------- Program: Code: ``` LBL A STO 4 √X INT STO 1 RCL 4 3 ÷ √X STO 2 RCL 4 RCL 1 X^2 - STO 3 2 ÷ √X STO 5 RCL 3 √X INT STO 0 ------------------------- LBL 1 RCL 1 RCL 2 X≤Y GTO 2 CLx FIX 9 PSE FIX 4 RTN ------------------------ LBL 2 RCL 0 RCL 5 X≤Y GTO 3 RCL 1 1 - STO 1 GTO 1 --------------------- LBL 3 RCL 3 RCL 0 X^2 - √X ENTER INT X=Y GTO 5 ------------------- LBL 4 RCL 0 1 - STO 0 GTO 2 ------------------ LBL 5 RCL 0 RCL 1 R/S GTO 4``` Gamo RE: (11C) Sums of Three Squares - Albert Chan - 01-07-2019 05:06 PM (01-07-2019 12:09 PM)Gamo Wrote:  Example: X^2 + Y^2 + Z^2 = 9876543210 Answer: X=77 Y=391 Z=99380 X=173 Y=359 Z=99380 there are many, many more ! X=388 Y=455 Z=99379 X=541 Y=680 Z=99377 X=553 Y=805 Z=99376 X=100 Y=1241 Z=99373 X=385 Y=1184 Z=99373 X=351 Y=1275 Z=99372 X=145 Y=1388 Z=99371 X=313 Y=1360 Z=99371 X=400 Y=1337 Z=99371 X=812 Y=1135 Z=99371 ... It might be better to test smaller number, say Year 2019. 2019 = 1² + 13² + 43² = 5² + 25² + 37² = 7² + 11² + 43² = 7² + 17² + 41² = 11² + 23² + 37² = 13² + 13² + 41² = 13² + 25² + 35² = 17² + 19² + 37² = 23² + 23² + 31²