As the title implies, I need help on a "Prime Number Producer". By that I mean the following: If someobody enters a number, they are supposed to get shown all the prime numbers up to the entered number.
This is what it's supposed to look like. Here's my code:
Dim Maximum As Double
Dim i As Integer
Dim y As Integer
Dim Prime As Boolean
For Maximum = 3 To y - 1 Step 2
If y Mod Maximum = 0 Then
Prime = False
Exit For
For i = 3 To Math.Sqrt(y) Step 2
Prime = True
lst_Prime.Items.Add(i)
Next
End If
Next Maximum
End Sub
The problem is that it isn't giving me out any numbers. I have tried checking it but I just can't seem to find the error
Do not worry, this is not supposed to be homework. It is merely a practice for me, programming-wise, and for somebody who wants to help teaching their children the prime numbers (so that they can double-check when they practise).
I thank you for your help in advance! :-)

New Topic/Question
Reply



MultiQuote







|