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

Published on 12 May 2024 09:40 PM

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

Source code in the 11l programming language

F non_square(Int n)
   R n + Int(floor(1/2 + sqrt(n)))

print_elements((1..22).map(non_square))

F is_square(n)
   R fract(sqrt(n)) == 0

L(i) 1 .< 10 ^ 6
   I is_square(non_square(i))
      print(‘Square found ’i)
      L.break
L.was_no_break
   print(‘No squares found’)

  

You may also check:How to resolve the algorithm Long multiplication step by step in the Scala programming language
You may also check:How to resolve the algorithm Rot-13 step by step in the FreeBASIC programming language
You may also check:How to resolve the algorithm Find limit of recursion step by step in the GAP programming language
You may also check:How to resolve the algorithm Distribution of 0 digits in factorial series step by step in the Raku programming language
You may also check:How to resolve the algorithm Munchausen numbers step by step in the zkl programming language