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

Published on 12 May 2024 09:40 PM
#Jq

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

Source code in the jq programming language

def A000037: . + (0.5 + sqrt | floor);

def is_square: sqrt | . == floor;

"For n up to and including 22:",
 (range(1;23) | A000037),
"Check for squares for n up to 1e6:",
 (range(1;1e6+1) | A000037 | select( is_square ))

$ jq -n -r -f sequence_of_non-squares.jq
For n up to and including 22:
2
3
5
6
7
8
10
11
12
13
14
15
17
18
19
20
21
22
23
24
26
27
Check for squares for n up to 1e6:
$


  

You may also check:How to resolve the algorithm SHA-1 step by step in the AArch64 Assembly programming language
You may also check:How to resolve the algorithm Address of a variable step by step in the Beef programming language
You may also check:How to resolve the algorithm Abundant odd numbers step by step in the J programming language
You may also check:How to resolve the algorithm Horizontal sundial calculations step by step in the Python programming language
You may also check:How to resolve the algorithm Visualize a tree step by step in the Sidef programming language