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

Published on 12 May 2024 09:40 PM

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

Source code in the miranda programming language

main :: [sys_message]
main = [Stdout (lay [first22, hassquare])]

first22 :: [char]
first22 = show (take 22 nonsqrseq)

hassquare :: [char]
hassquare = "Square found", if or [issquare n | n<-take 1000000 nonsqrseq]
          = "No square found", otherwise

issquare :: num->bool
issquare n = n == (entier (sqrt n))^2

nonsqrseq :: [num]
nonsqrseq = map nonsqr [1..]

nonsqr :: num->num
nonsqr n = n + entier (0.5 + sqrt n)

  

You may also check:How to resolve the algorithm Perfect shuffle step by step in the Picat programming language
You may also check:How to resolve the algorithm Ethiopian multiplication step by step in the Arturo programming language
You may also check:How to resolve the algorithm Chaos game step by step in the Emacs Lisp programming language
You may also check:How to resolve the algorithm MD5/Implementation step by step in the Racket programming language
You may also check:How to resolve the algorithm Factorial base numbers indexing permutations of a collection step by step in the Haskell programming language