How to resolve the algorithm Sub-unit squares step by step in the Arturo programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Sub-unit squares step by step in the Arturo programming language
Table of Contents
Problem Statement
A sub-unit square is a square number (product of two identical non-negative integers) that remains a square after having a 1 subtracted from each digit in the square.
The number 1 is a sub-unit square. 1 - 1 is 0, which is also a square, though it's kind-of a degenerate case. The number 3136 is a sub-unit square. 3136 (56²) with unit 1 subtracted from each digit is 2025 (45²).
A sub-unit square cannot contain a digit zero (0) since zero minus one is negative one. Every known sub-unit square, with the exception of 1, ends with the digits 36.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Sub-unit squares step by step in the Arturo programming language
Source code in the arturo programming language
allSquares: map 1..1000000 'x -> x^2
subUnits: allSquares | select 'z -> not? some? digits z 'w -> w=0
| select 'x -> contains? allSquares to :integer join map digits x 'k -> k-1
print ["The first" size subUnits "sub-unit squares:"]
print subUnits
You may also check:How to resolve the algorithm Keyboard input/Keypress check step by step in the C programming language
You may also check:How to resolve the algorithm Fractran step by step in the Go programming language
You may also check:How to resolve the algorithm Flow-control structures step by step in the AWK programming language
You may also check:How to resolve the algorithm Dutch national flag problem step by step in the Fortran programming language
You may also check:How to resolve the algorithm Cholesky decomposition step by step in the Raku programming language