How to resolve the algorithm Sequence of non-squares step by step in the Delphi programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Sequence of non-squares step by step in the Delphi programming language
Table of Contents
Problem Statement
Show that the following remarkable formula gives the sequence of non-square natural numbers:
This is sequence A000037 in the OEIS database.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Sequence of non-squares step by step in the Delphi programming language
Source code in the delphi programming language
program Sequence_of_non_squares;
uses
System.SysUtils, System.Math;
function nonsqr(i: Integer): Integer;
begin
Result := Trunc(i + Floor(0.5 + Sqrt(i)));
end;
var
i: Integer;
j: Double;
begin
for i := 1 to 22 do
write(nonsqr(i), ' ');
Writeln;
for i := 1 to 999999 do
begin
j := Sqrt(nonsqr(i));
if (j = Floor(j)) then
Writeln(i, 'Is Square');
end;
end.
You may also check:How to resolve the algorithm Compile-time calculation step by step in the D programming language
You may also check:How to resolve the algorithm Arbitrary-precision integers (included) step by step in the Maple programming language
You may also check:How to resolve the algorithm Exceptions step by step in the Make programming language
You may also check:How to resolve the algorithm Multiplicative order step by step in the Kotlin programming language
You may also check:How to resolve the algorithm Horner's rule for polynomial evaluation step by step in the Ada programming language