How to resolve the algorithm Wieferich primes step by step in the ALGOL 68 programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Wieferich primes step by step in the ALGOL 68 programming language

Table of Contents

Problem Statement

In number theory, a Wieferich prime is a prime number p such that p2 evenly divides 2(p − 1) − 1 .

It is conjectured that there are infinitely many Wieferich primes, but as of March 2021,only two have been identified.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Wieferich primes step by step in the ALGOL 68 programming language

Source code in the algol programming language

BEGIN # find Wierferich Primes: primes p where p^2 evenly divides 2^(p-1)-1  #

    INT max number = 5 000; # maximum number we will consider                #
    # set precision of LONG LONG INT - p^5000 has over 1500 digits           #
    PR precision 1600 PR
    PR read "primes.incl.a68" PR                    # include prime utlities #
    # get a list of primes up to max number                                  #
    []INT prime = EXTRACTPRIMESUPTO max number
                     FROMPRIMESIEVE PRIMESIEVE max number;

    # find the primes                                                        #
    INT           p pos            := LWB prime;
    LONG LONG INT two to p minus 1 := 1;
    INT           power            := 0;
    INT           w count          := 0;
    WHILE w count < 2 DO
        INT p = prime[ p pos ];
        WHILE power < ( p - 1 ) DO
            two to p minus 1 *:= 2;
            power            +:= 1
        OD;
        IF ( two to p minus 1 - 1 ) MOD ( p * p ) = 0 THEN
            print( ( " ", whole( p, 0 ) ) );
            w count +:= 1
        FI;
        p pos +:= 1
    OD
END

  

You may also check:How to resolve the algorithm A+B step by step in the EDSAC order code programming language
You may also check:How to resolve the algorithm Hello world/Newbie step by step in the Coq programming language
You may also check:How to resolve the algorithm Play recorded sounds step by step in the AutoHotkey programming language
You may also check:How to resolve the algorithm Munching squares step by step in the BQN programming language
You may also check:How to resolve the algorithm Variables step by step in the Icon and Unicon programming language