This site requires JavaScript, please enable it in your browser!
Greenfoot back

Report as inappropriate.

bourne presents ...



So this was my experiment once when influenced to play with primes a couple hours from a math class.

To the left is a graph of a particular distribution of the first 1900 primes.

PrimeUtil CLASS:
Stores a growing list of known primes.
Can check if a given integer is a prime.
Can retrieve the i'th prime.
Can determine the result of the pi function (prime-counting function) of a given double.
Updates list of primes as needed for queries.

Checking a candidate for the next prime (to be added to growing list) has running time: n (the size of the growing list of known primes)

Determining an integer is prime has running time: lg n (binary search) *

Evaluating pi has running time: lg n (binary search) *

*not including running time of finding next primes when list is insufficient.

1766 views / 408 in the last 7 days

Tags: with-source gui bourne primes prime

open in greenfoot

There is no HTML 5 translation of this scenario available.
View legacy version (requires Java plugin)

This scenarios uses Java features that are not available for use after conversion to HTML 5. Please try the legacy version, which requires the Java plugin to be installed.

No Comments

Want to leave a comment? You must first log in.

Who likes this?

No votes yet.