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

Published on 12 May 2024 09:40 PM

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

Source code in the setl programming language

program sequence_of_non_squares;
    print([nonsquare n : n in [1..22]]);

    if exists n in [1..1000000] | is_square nonsquare n then
        print("Found square", nonsquare n, "at", n);
    else
        print("No squares found up to 1 million");
    end if;

    op is_square(n);
        return (floor sqrt n)**2 = n;
    end op;

    op nonsquare(n);
        return n + floor(0.5 + sqrt n);
    end op;
end program;

  

You may also check:How to resolve the algorithm Towers of Hanoi step by step in the ERRE programming language
You may also check:How to resolve the algorithm Longest common substring step by step in the PowerShell programming language
You may also check:How to resolve the algorithm Hello world/Text step by step in the Cobra programming language
You may also check:How to resolve the algorithm Equilibrium index step by step in the PHP programming language
You may also check:How to resolve the algorithm Narcissistic decimal number step by step in the J programming language