How to resolve the algorithm Wieferich primes step by step in the FreeBASIC programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Wieferich primes step by step in the FreeBASIC 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 FreeBASIC programming language
Source code in the freebasic programming language
#include "isprime.bas"
function iswief( byval p as uinteger ) as boolean
if not isprime(p) then return 0
dim as integer q = 1, p2 = p^2
while p>1
q=(2*q) mod p2
p = p - 1
wend
if q=1 then return 1 else return 0
end function
for i as uinteger = 1 to 5000
if iswief(i) then print i
next i
You may also check:How to resolve the algorithm Apply a digital filter (direct form II transposed) step by step in the FreeBASIC programming language
You may also check:How to resolve the algorithm Naming conventions step by step in the FreeBASIC programming language
You may also check:How to resolve the algorithm Find if a point is within a triangle step by step in the FreeBASIC programming language
You may also check:How to resolve the algorithm Floyd-Warshall algorithm step by step in the FreeBASIC programming language
You may also check:How to resolve the algorithm Sort an array of composite structures step by step in the FreeBASIC programming language