Three Euler's Sieves and a Fast Prime Generator (Functional Pearl)

11/24/2018
by   Ivano Salvo, et al.
0

The Euler's Sieve refines the Sieve of Eratosthenes to compute prime numbers, by crossing off each non prime number just once. Euler's Sieve is considered hard to be faithfully and efficiently coded as a purely functional stream based program. We propose three Haskell programs implementing the Euler's Sieve, all based on the idea of generating just once each composite to be crossed off. Their faithfulness with respect to the Euler's Sieve is up to costly stream unions imposed by the sequential nature of streams. Our programs outperform classical naive stream based prime generators such as trial division, but they are asymptotically worse than the O'Neill `faithful' Sieve of Eratosthenes. To circumvent the bottleneck of union of streams, we integrate our techniques inside the O'Neill program, thus obtaining a fast prime generator based on the Euler's Sieve and priority queues.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
06/10/2021

On the 4-adic complexity of the two-prime quaternary generator

R. Hofer and A. Winterhof proved that the 2-adic complexity of the two-p...
research
02/15/2021

Approximating viscosity solutions of the Euler system

Applying the concept of S-convergence, based on averaging in the spirit ...
research
06/23/2020

A Note on the Cross-Correlation of Costas Permutations

We build on the work of Drakakis et al. (2011) on the maximal cross-corr...
research
03/09/2018

On k-error linear complexity of pseudorandom binary sequences derived from Euler quotients

We investigate the k-error linear complexity of pseudorandom binary sequ...
research
11/27/2018

Class of scalable parallel and vectorizable pseudorandom number generators based on non-cryptographic RSA exponentiation ciphers

Parallel supercomputer-based Monte Carlo and stochastic simulatons requi...
research
11/24/2017

A Fowler-Nordheim Integrator can Track the Density of Prime Numbers

"Does there exist a naturally occurring counting device that might eluci...
research
09/17/2023

On the Connection Between Riemann Hypothesis and a Special Class of Neural Networks

The Riemann hypothesis (RH) is a long-standing open problem in mathemati...

Please sign up or login with your details

Forgot password? Click here to reset