ScratchData LogoScratchData
Back to PullJosh's profile

Prime Check Methods Comparison

PUPullJosh•Created January 23, 2016
Prime Check Methods Comparison
53
38
609 views
View on Scratch

Instructions

This project compares the speed of different methods for determining whether a number is prime. When entering a number to check, you may also enter an expression (such as 2^17-1). Each of the methods available in the project is listed below: 1. Basic division - Check every integer from 2 to one less than the entered number and see if it is a factor. Very basic. 2. Intelligent Division - Similar to basic division, but we don't check any even numbers except for 2. Only checks up to the square root of the entered number. 3. Sieve of Eratosthenes - This one is difficult to explain, but the gif on this wikipedia page does a good job: https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes 4. Lucas-Lehmer - This one only works on numbers which follow the form 2^n - 1. It uses a special sequence which is explained here: https://www.youtube.com/watch?v=lEvXcTYqtKU

Description

================ IMPORTANT NOTE: ================= This project can handle numbers which are pretty large. However, there comes a point when the numbers are too large to manage. Once the numbers get large enough (we're talking 10+ digits long), Scratch can't accurately perform math operations and you may get a faulty result. For example, 2^31 - 1 is prime but will return "not prime" in this project. Credit: - Uses @Griffpatch's Mathematic Evaluator: https://scratch.mit.edu/projects/23024829/

Project Details

Project ID95219132
CreatedJanuary 23, 2016
Last ModifiedJanuary 25, 2016
SharedJanuary 25, 2016
Visibilityvisible
CommentsAllowed