How to resolve the algorithm Sequence of non-squares step by step in the Transd programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Sequence of non-squares step by step in the Transd 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 Transd programming language
Source code in the transd programming language
#lang transd
MainModule: {
nonsqr: (λ i Int()
(ret (+ i (to-Int (floor (+ 0.5 (sqrt i))))))),
_start: (lambda locals: d Double()
(for i in Range(1 23) do
(textout (nonsqr i) " "))
(for i in Range(1 1000001) do
(= d (sqrt (nonsqr i)))
(if (eq d (floor d))
(throw String("Square: " i))))
(textout "\n\nUp to 1 000 000 - no squares found.")
)
}
You may also check:How to resolve the algorithm Literals/Integer step by step in the REBOL programming language
You may also check:How to resolve the algorithm Greatest element of a list step by step in the Run BASIC programming language
You may also check:How to resolve the algorithm Bitmap/Bresenham's line algorithm step by step in the Prolog programming language
You may also check:How to resolve the algorithm Convert seconds to compound duration step by step in the Pascal programming language
You may also check:How to resolve the algorithm Damm algorithm step by step in the MAD programming language