How to resolve the algorithm Square but not cube step by step in the Raku programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Square but not cube step by step in the Raku programming language
Table of Contents
Problem Statement
Show the first 30 positive integers which are squares but not cubes of such integers. Optionally, show also the first 3 positive integers which are both squares and cubes, and mark them as such.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Square but not cube step by step in the Raku programming language
Source code in the raku programming language
my @square-and-cube = map { .⁶ }, 1..Inf;
my @square-but-not-cube = (1..Inf).map({ .² }).grep({ $_ ∉ @square-and-cube[^@square-and-cube.first: * > $_, :k]});
put "First 30 positive integers that are a square but not a cube: \n", @square-but-not-cube[^30];
put "\nFirst 15 positive integers that are both a square and a cube: \n", @square-and-cube[^15];
You may also check:How to resolve the algorithm Heronian triangles step by step in the Phix programming language
You may also check:How to resolve the algorithm System time step by step in the AWK programming language
You may also check:How to resolve the algorithm Barnsley fern step by step in the Processing programming language
You may also check:How to resolve the algorithm Fibonacci n-step number sequences step by step in the APL programming language
You may also check:How to resolve the algorithm Population count step by step in the Haskell programming language