How to resolve the algorithm Numbers which are not the sum of distinct squares step by step in the EasyLang programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Numbers which are not the sum of distinct squares step by step in the EasyLang programming language

Table of Contents

Problem Statement

Integer squares are the set of integers multiplied by themselves: 1 x 1 = 1, 2 × 2 = 4, 3 × 3 = 9, etc. ( 1, 4, 9, 16 ... ) Most positive integers can be generated as the sum of 1 or more distinct integer squares. Many can be generated in multiple ways: The number of positive integers that cannot be generated by any combination of distinct squares is in fact finite:

Find and show here, on this page, every positive integer than cannot be generated as the sum of distinct squares. Do not use magic numbers or pre-determined limits. Justify your answer mathematically.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Numbers which are not the sum of distinct squares step by step in the EasyLang programming language

Source code in the easylang programming language

maxNumber = 324
len isSum[] maxNumber
maxSquare = floor sqrt maxNumber
# 
proc flagSum currSum sqPos . .
   nextSum = currSum + sqPos * sqPos
   if nextSum <= maxNumber
      isSum[nextSum] = 1
      for i = sqPos + 1 to maxSquare
         flagSum nextSum i
      .
   .
.
for i = 1 to maxSquare
   flagSum 0 i
.
for i = 1 to maxNumber
   if isSum[i] = 0
      write i & " "
   .
.

  

You may also check:How to resolve the algorithm Function definition step by step in the Pascal programming language
You may also check:How to resolve the algorithm Repeat a string step by step in the TorqueScript programming language
You may also check:How to resolve the algorithm Palindrome detection step by step in the Lasso programming language
You may also check:How to resolve the algorithm Colour pinstripe/Display step by step in the Visual Basic .NET programming language
You may also check:How to resolve the algorithm Harshad or Niven series step by step in the 11l programming language