Code Monkey home page Code Monkey logo

prime-sieve-dart's Introduction

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.

prime-sieve-dart's People

Contributors

marcelwaldvogel avatar hacatu avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.