I'm sure many of you have already made this before. But I don't believe I ever have, and I've programmed since the mid-80's. I also got zero help from anyone or any A.I. this time.
It asks you how many numbers you wish to calculate in sequence from 1 to your number. The limit is 100000. While it is doing it, it places the number on PrimeNumbers.txt file in the same directory as this program. So it's best to make a new directory before you start it. When it is finished it automatically opens your Notepad to display all the numbers. At the end of the list of numbers it will tell you how many numbers are on the list. Therefore, this will only work on a Windows computer I believe since it uses SHELL and Notepad.
If you decide to change the limit of the amount of prime numbers it makes, just be aware that computers can heat up and break if over-used. I set the limit at 100000 numbers to calculate and the primes placed on the PrimeNumbers.txt file. I hold no responsibility of any over-use in any way, as usual.
It asks you how many numbers you wish to calculate in sequence from 1 to your number. The limit is 100000. While it is doing it, it places the number on PrimeNumbers.txt file in the same directory as this program. So it's best to make a new directory before you start it. When it is finished it automatically opens your Notepad to display all the numbers. At the end of the list of numbers it will tell you how many numbers are on the list. Therefore, this will only work on a Windows computer I believe since it uses SHELL and Notepad.
If you decide to change the limit of the amount of prime numbers it makes, just be aware that computers can heat up and break if over-used. I set the limit at 100000 numbers to calculate and the primes placed on the PrimeNumbers.txt file. I hold no responsibility of any over-use in any way, as usual.
Code: (Select All)
'Prime Number Calculator by SierraKen
'December 26, 2024
'I got no help from anyone or any A.I.
'
'If you change any of this code, please do not change the limit to more than 100000.
'I'm sure it can do much more but I hold no responsibility if this program overworks your computer in any way.
_Title "Prime Number Calculator"
Screen _NewImage(800, 600, 32)
start:
Cls
Print: Print: Print
Print " Prime Number Calculator by SierraKen"
Print: Print: Print
Print " This will calculate all prime numbers from 1 up to your given number (1-100000)."
Print " A prime number is a number that can only be divided by itself and 1."
Print " Then it will save the numbers to PrimeNumbers.txt and will"
Print " open it in Notepad when it is finished."
Print " The total amount of prime numbers will be shown at the bottom of the text file."
Print " Make sure and close this program when it is finished."
Print: Print: Print
Input " How many numbers do you wish to calculate in sequence between 1-100000: "; n
If n > 100000 Or n < 1 Or n <> Int(n) Then GoTo start:
Print
Open "PrimeNumbers.txt" For Output As #1
Do
t = t + 1
If t = 1 Or t = 2 Or t = 3 Then
Print Str$(t) + ", ";
Print #1, t
a = a + 1
GoTo nex:
End If
For tt = 2 To t - 1
If t / tt = Int(t / tt) Then GoTo nex:
Next tt
Print Str$(t) + ", ";
Print #1, t
a = a + 1
nex:
Loop Until t = n
Print #1, ""
Print #1, "Total Prime Numbers Between 1 and " + Str$(t) + ": " + Str$(a)
Close #1
Shell "CMD /C START /MAX notepad " + "PrimeNumbers.txt"