How to resolve the algorithm Safe primes and unsafe primes step by step in the Frink programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Safe primes and unsafe primes step by step in the Frink programming language

Table of Contents

Problem Statement

Show all output here.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Safe primes and unsafe primes step by step in the Frink programming language

Source code in the frink programming language

safePrimes[end=undef] := select[primes[5,end], {|p| isPrime[(p-1)/2] }]
unsafePrimes[end=undef] := select[primes[2,end], {|p| p<5 or isPrime[(p-1)/2] }]

println["First 35 safe primes:  " + first[safePrimes[], 35]]
println["Safe primes below  1,000,000: " + length[safePrimes[1_000_000]]]
println["Safe primes below 10,000,000: " + length[safePrimes[10_000_000]]]

println["First 40 unsafe primes:  " + first[unsafePrimes[], 40]]
println["Unsafe primes below  1,000,000: " + length[unsafePrimes[1_000_000]]]
println["Unsafe primes below 10,000,000: " + length[unsafePrimes[10_000_000]]]

  

You may also check:How to resolve the algorithm Even or odd step by step in the Ring programming language
You may also check:How to resolve the algorithm Problem of Apollonius step by step in the FreeBASIC programming language
You may also check:How to resolve the algorithm Greatest common divisor step by step in the Wren programming language
You may also check:How to resolve the algorithm Substring/Top and tail step by step in the Nim programming language
You may also check:How to resolve the algorithm Constrained random points on a circle step by step in the Locomotive Basic programming language