How to resolve the algorithm Square but not cube step by step in the ALGOL-M programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Square but not cube step by step in the ALGOL-M 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 ALGOL-M programming language
Source code in the algol-m programming language
begin
integer function square(x);
integer x;
square := x * x;
integer function cube(x);
integer x;
cube := x * x * x;
integer c, s, seen;
seen := 0;
while seen < 30 do
begin
while cube(c) < square(s) do
c := c + 1;
if square(s) <> cube(c) then
begin
if (seen/5 <> (seen-1)/5) then write("");
writeon(square(s));
seen := seen + 1;
end;
s := s + 1;
end;
end
You may also check:How to resolve the algorithm Window management step by step in the Nim programming language
You may also check:How to resolve the algorithm Fivenum step by step in the Groovy programming language
You may also check:How to resolve the algorithm Sierpinski triangle/Graphical step by step in the Lua programming language
You may also check:How to resolve the algorithm Break OO privacy step by step in the Lua programming language
You may also check:How to resolve the algorithm Sorting algorithms/Cocktail sort step by step in the PicoLisp programming language