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

Published on 12 May 2024 09:40 PM
#J

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

Source code in the j programming language

   rf=: + 0.5 <.@+ %:       NB.  Remarkable formula

   rf 1+i.22               NB.  Results from 1 to 22
2 3 5 6 7 8 10 11 12 13 14 15 17 18 19 20 21 22 23 24 26 27

   +/ (rf e. *:) 1+i.1e6   NB.  Number of square RFs <= 1e6
0


  

You may also check:How to resolve the algorithm Equilibrium index step by step in the XPL0 programming language
You may also check:How to resolve the algorithm World Cup group stage step by step in the Ruby programming language
You may also check:How to resolve the algorithm Abbreviations, simple step by step in the Scala programming language
You may also check:How to resolve the algorithm Knapsack problem/Unbounded step by step in the REXX programming language
You may also check:How to resolve the algorithm Truncate a file step by step in the OCaml programming language