Search:
Prime-Number-Spotter
 Image: Author: FRA32Group: TechnicalFilesize: 23.01 kBDate added: 2016-01-08Rating: 5Downloads: 614Views: 275Comments: 8Ratings: 1Times favored: 0Made with: Algodoo v2.1.0Tags: Scene tag [scene]123431[/scene] This scene contains an object that maps the number line as a spiral and checks if it hits a prime number by dividing it by every preceeding number until it hit's a clean division. Note how the prime numbers form visible diagonals when viewed after a while. Fun fact: the 25 black boxes were created by copying a single box with the text "1" and the onSpawn code (e)=>{text = "" + (math.toint(text)+1)} multiple times, automatically increasing the number everytime I duplicate a box. Edit 1: Increased speed by making the calculator automatically register the number as prime if the dividing counter is larger than the current checked number divided by 2 (since there's no other natural number other than 1 and 0 lower than 2) Edit 2: Altered the code for even more calculation speed at larger number scales by automatically skipping everything past the square root of the number , since the following numbers would just be inversions of the previous ones(i.e 100 / 20 = 5, 100 / 5 = 20 -> if X / Y = Z and X % Y != 0 -> X%Z is not neccessary to be calculates since Z is not a natural number). The only exception is 2 as it's square root is right between 2 and 1 and so needs to be handled manually. Edit 3: Removed 1 from the prime numbers Edit 4: Removed the output of non-prime numbers, increased stepping speed by skipping all even numbers except 2.
Last edited at 2016/07/03 21:50:38 by FRA32