Given : k different primes say a1, a2, ....., ak
Purpose . The minimum number of perfect squares required to record the product of these prime numbers as the sum of perfect squares.
Examples:
k = 2, a1 = 3, a2 = 5 a1*a2 = 15 = 9 + 4 + 1 + 1 and the sum of 4 perfect squares
k = 3, a1 = 2, a2 = 5, a3 = 11 a1*a2*a3 = 110 = 100 + 9 + 1 i.e. sum of 3 perfect squares
My algorithm
let p = a1*a2*...........*ak
counter = 0 while p != 0: find the largest perfect square <= p say z p = pz counter = counter + 1 return counter
I tested it for a few examples. That seems right to me. But it is wrong to generalize based on a few examples. How to prove it (if the algorithm is correct)?
source share