How to resolve the algorithm Sequence of non-squares step by step in the Wren programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Sequence of non-squares step by step in the Wren 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 Wren programming language
Source code in the wren programming language
import "/fmt" for Fmt
System.print("The first 22 numbers in the sequence are:")
System.print(" n term")
for (n in 1...1e6) {
var s = n + (0.5 + n.sqrt).floor
var ss = s.sqrt.round
if (ss * ss == s) {
Fmt.print("The $r number in the sequence $d = $d x $d is a square.", n, s, ss, ss)
return
}
if (n <= 22) Fmt.print(" $2d $2d", n, s)
}
System.print("\nNo squares were found in the first 999,999 terms.")
You may also check:How to resolve the algorithm 100 prisoners step by step in the Perl programming language
You may also check:How to resolve the algorithm Mertens function step by step in the C programming language
You may also check:How to resolve the algorithm Evolutionary algorithm step by step in the MATLAB programming language
You may also check:How to resolve the algorithm Koch curve step by step in the Sidef programming language
You may also check:How to resolve the algorithm Count occurrences of a substring step by step in the zkl programming language