(11C) Random Prime Number Generator
|
10-21-2018, 05:09 PM
(This post was last modified: 10-21-2018 05:12 PM by Dieter.)
Post: #8
|
|||
|
|||
RE: (11C) Random Prime Number Generator
(10-21-2018 03:22 AM)Gamo Wrote: Sure do, I like to see the update version. OK - but this is not as sophisticated as the program Thomas posted. ;-) For four-digit prime numbers your program requires two changes. First change the program start this way: Code: LBL E This generates an odd random number between 1001 and 9999. Take a closer look at how it works: first a random integer between 0 and 4499 is generated. Then this is doubled, which yields an even integer between 0 and 8998. Finally 1001 is added, resulting in an odd random integer between 1001 and 9999. Note: due to roundoff issues the largest prime candidate can be 10001. But since 10001 is not a prime number it will not be returned. Finally remove the complete LBL 3 part at the end. This seems to be left from another prime number program. Replace the "GTO 3" line with "GTO E". After these changes the program will generate four-digit random integers. Dieter |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)