How to resolve the algorithm Numbers which are not the sum of distinct squares step by step in the Quackery 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 Quackery 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 Quackery programming language
Source code in the quackery programming language
[ [] swap
behead swap
witheach
[ 2dup = iff
drop done
dip join ]
join ] is unique ( [ --> [ )
[ stack ] is cut ( --> s )
[ -1 cut put
1 temp put
1 swap
behead swap
witheach
[ tuck - -1 = iff
[ dip 1+
over temp share
> if
[ over temp replace
i^ cut replace ] ]
else
[ nip 1 swap ] ]
2drop
temp take cut take ] is maxrun ( [ --> n n )
[ [] swap 0 over
witheach [ bit | ]
swap -1 peek times
[ dup i^ bit & not if
[ dip [ i^ join ] ] ]
drop ] is missing ( [ --> [ )
1 temp put
' [ 0 ]
1 from
[ dup witheach
[ temp share +
join ]
sort unique
dup maxrun drop
index 2 + temp tally
temp share > iff
end done
2 incr ]
temp release
dup maxrun
nip split
drop missing
say "Numbers that are not the sum of distinct squares:"
cr echo
You may also check:How to resolve the algorithm Penney's game step by step in the Racket programming language
You may also check:How to resolve the algorithm Ethiopian multiplication step by step in the D programming language
You may also check:How to resolve the algorithm Arithmetic-geometric mean/Calculate Pi step by step in the Delphi programming language
You may also check:How to resolve the algorithm Cistercian numerals step by step in the Perl programming language
You may also check:How to resolve the algorithm Carmichael 3 strong pseudoprimes step by step in the Racket programming language