How to resolve the algorithm Sequence of non-squares step by step in the zkl programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Sequence of non-squares step by step in the zkl 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 zkl programming language

Source code in the zkl programming language

fcn seq(n){n + (0.5+n.toFloat().sqrt()).floor()}
[1..22].apply(seq).toString(*).println();

fcn isSquare(n){n.toFloat().sqrt().modf()[1]==0.0}
isSquare(25)  //-->True
isSquare(26)  //-->False
[2..0d1_000_000].filter(fcn(n){isSquare(seq(n))}).println();

  

You may also check:How to resolve the algorithm String case step by step in the Peloton programming language
You may also check:How to resolve the algorithm Factors of an integer step by step in the Racket programming language
You may also check:How to resolve the algorithm Pairs with common factors step by step in the Perl programming language
You may also check:How to resolve the algorithm Vampire number step by step in the Common Lisp programming language
You may also check:How to resolve the algorithm Zeckendorf arithmetic step by step in the 11l programming language