LoginLogin

PRIME

Root / Submissions / [.]

PtcguyCreated:
Download:7K23N4J6
Version:1.6Size:7.94 KB
This program, once given a number to start with, checks all numbers above it for primality; if it finds a prime number, it prints it to the screen with a user-defined delay. Updates in 1.6: A lot has happened since 1.2. Now you can tell the program when to stop checking for numbers. You can also tell it to save to a file (with a fixed filename for now) when it's done checking. Also, the prime checking part of the program is now a function - simply copy the DEF - END block from the bottom of the PRIME program into yours to use it. It returns a zero if the number is not prime and a 1 if it is. Finally, the LOADPRIME program can load the file that prime numbers are saved to (this version comes with one with the primes from 1-1000) into a program slot (1-3) for easy viewing. Or they can be printed to the screen, although this feature is not really develloped so I wouldn't recommend using it. If you want to load the primes to an array, follow the instructions in the code of the LOADPRIME program. Updates in 1.2: Input system for numbers uses built-in INPUT function. The program also enables the user to specify a delay that will be waited in between each number that is printed. Also, when the prime numbers are printed, they won't wrap around the edge of the screen like in 1.1. The pause function is also more responsive. Future plans:
  • Making it more user-friendly
  • Adding the ability to change the name of the file that will be saved
  • Adding the ability to not print the numbers
  • Adding a benchmarking section of the program
  • Adding the ability to check for the first n primes
  • Adding the ability (in the function) to check for all of the prime and non-prime factors
If you have more ideas, add them in the comments!

Instructions:

Instructions for 1.6: For PRIME: After running the program, it will ask you from what number you want it to check for primality. Then, it will ask you for the delay you want it to wait in between showing prime numbers (in 60ths of a second). Then it will ask you at what number you want it to stop (it won't check this number) (0 means it will never stop). Finally, it will ask you if you want it to save the prime numbers to a file (it won't save if 0 was entered for when to stop). It will show you your selections: press B to go to the main program or x to re-input the numbers. Once you're at the main program, press A to start. Pressing UP or L will pause it and pressing DOWN or R will unpause it (it indicates at the top if it's paused or running). If you set a limit, it will end the program once it has reached it unless if you've told it to save - then, it will pop up a dialog box asking you to confirm if you want it to save and then the program will end. For LOADPRIME: After running the program, press B to load the numbers into a program slot or X to print them to the screen. If you decide to load to a program slot, it will ask you for which slot (1-3, since slot 0 will usually be taken up by the program) and then load it into the slot, one number per line. If you decide to print to the screen, it will print the numbers to the screen and then quit out of the program. There is no pause and it will simply print numbers until it's done, so use of this feature is discouraged. Instructions for 1.2 (public key: X3EKQXDM): The program will initially ask you for a number, from which it will start checking for prime numbers. It will also ask you for the delay inbetween each time a number is printed (in 60ths of a second). Press B to go to the main program or X to re-input those numbers. At the main screen, press A to start generating prime numbers. UP and L pause; DOWN and R unpause. Instructions for 1.1 (public key:N4NE23HJ): The program's first screen is where you input the number you want the program to start checking from. Pressing up and down add and subtract one respectively, L and R add and subtract 10 respectively, and X multiplies the number by 10 while B does the opposite. This means that if you want to enter, say, 1834, you would add one with one press of up, multiply it by 10 with X, add 8 with 8 presses of up, etc. until 1834 is reached. Once the desired number (between 0 and 10,000,000,000)is entered, press Y and the program will go to the number-checking section. Press A to start checking numbers (the entered number and all numbers above that) and prime numbers are printed to the screen. Pressing up or L pauses the program, and pressing down or R unpauses it. Instructions for 1.0 (public key: 7ANN23HJ) Press A and the program will start checking for prime numbers from one and won't stop. Press UP or L to pause and DOWN or R to unpause.

Notes:

This program is a more feature-filled, slightly optimized, and highly commented version of my petit computer program. Smilebasic can handle numbers in the billions, making this program able to check MUCH larger numbers than the petit computer version. It can save and recall prime numbers from a saved file.

No posts yet (will you be the first?)