This app will calculate every prime number from 1 to 100,000. It also puts it on a text file called PrimeNumbers.txt and will open Windows Notepad automatically and display all the numbers at the end.
Please don't increase the 100000 limit in this code. I don't want anyone's computer to break. Use at your own risk. With a Windows 11 computer, I read that it can do a million, but I wouldn't gamble.
Please don't increase the 100000 limit in this code. I don't want anyone's computer to break. Use at your own risk. With a Windows 11 computer, I read that it can do a million, but I wouldn't gamble.
Code: (Select All)
'Prime Number Calculator by SierraKen
'December 26, 2024
'I got no help from anyone or anything this time!
'
'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"