Skip to content

A prime number generator written in Dart, using Euler's sieve and a wheel size of 210 based on https://github.com/hacatu/Prime-Sieve

License

Notifications You must be signed in to change notification settings

MarcelWaldvogel/Prime-Sieve-Dart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Prime-Sieve-Dart

A prime number generator written in Dart, using Euler's sieve and a wheel size of 210.

The code is based as closely as possible on hacatu's Prime-Sieve.

Performance

The performance of the prime determination is about half as fast as the C implementation. On my machine, it requires about 7.5 s (Dart) instead of 3.5 s (C) to find all primes up to 10⁹.

(Printing, however, is way slower, instead of 3.5 s for the C version, the output takes about 80 s.)

More performance or flexibility?

If you need more performance (about 20x) or flexibility (e.g., iterators), Kim Walisch's primesieve C/C++ library is the way to go. It also may come pre-packaged with/for your OS.

Usage

dart example/prime_sieve.dart [options] <max>

Determine primality for all numbers up to max. max should not exceed about 2⁶⁰ (or 2⁵⁰, when translating to JavaScript) or the size of your memory, whatever is smaller.

Options

  • --help: Print help
  • --[no-]count: Whether to output the count of primes found. (Default: true.)
  • --[no-]print: Whether to output the primes after calculating them. (Default: true.)
  • --query: Whether to enter a query input loop for primality tests after possibly printing the values.

About

A prime number generator written in Dart, using Euler's sieve and a wheel size of 210 based on https://github.com/hacatu/Prime-Sieve

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages