Find numbers which can be expressed as Sum of Squares of Positive Integers
No License
First, some examples :
17 * 29 * 41 * 149 * 113 = 340326281
= 2984^2 + 18205^2 = 18220^2 + 2891^2
509 * 853 * 769 = 333882113
= 11528^2 + 14177^2 = 18272^2 + 127^2
The Main programme is the subfunction Test_Random_2_Squares within the function : Runs_Of_Test_Random_2_Squares_1.m which tries to find 2 sets of arrays of positive integers such that the corresponding sums of squares of the numbers in the 2 arrays equals the product of r no of Prime Factors.
The function : find_the_2_Squares_from_the_Sum ( Sum ) forms the heart of this suite, which can also be independently used.
Whereas, currently (Aug 2005), the top function : Runs_Of_Test_Random_2_Squares_1.m
deals only with prime factors of the form (4*n+1), the heart-function : fnd_the_2_Squares_from_the_Sum.m can still be independently used to find sum of squares - even if the factors include primes of type (4*n-1), or even 2.
The various steps of the subfunction Test_Random_2_Squares.m are :
1) This overall pgm first calls Prime_Fctrs_Of_Sum_Of_2_Sqrs(N)
to obtain the list of primes which are <= N, and which are of the form (4n+1).
2) Next, it randomly chooses "r" nos from the output primes_N_4nPlus1 of the above call.
3) Next, it calls [ Match_Rnded_Array_1, Match_Rnded_Array_2 ] =
find_the_2_Squares_from_the_Sum(Sum) ;
to get the 2 sets of arrays.
*************
There are some open queries given in find_the_2_Squares_from_the_Sum ( Sum ), the answers to which will help us understand this concept better.
Thanks in advance to those who are sending clarifications.
Cite As
Sundar Krishnan (2025). Find numbers which can be expressed as Sum of Squares of Positive Integers (https://www.mathworks.com/matlabcentral/fileexchange/5398-find-numbers-which-can-be-expressed-as-sum-of-squares-of-positive-integers), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform Compatibility
Windows macOS LinuxCategories
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
Version | Published | Release Notes | |
---|---|---|---|
1.0.0.0 | Logic of find_the_2_Squares_from_the_Sum is changed. |