[SOURCE]Prime Number Calculator 02-07-2011, 03:23 PM
#1
Hi 
So, Recently I had some bad marks from maths coz I'm not very interested in the subject we are doing school...
Anyway, my teacher agreed that if I amaze him somehow, he will give me a bonus to my marks
So I made this little prime number calculator.
It's not the MOST efficient way, but also not least.
Function:
Usage:
NOTE: Yes, I did get the bonus

So, Recently I had some bad marks from maths coz I'm not very interested in the subject we are doing school...
Anyway, my teacher agreed that if I amaze him somehow, he will give me a bonus to my marks

So I made this little prime number calculator.
It's not the MOST efficient way, but also not least.
Function:
Code:
Function IsPrimeNumber(ByVal i As Double) As Boolean
MySqrt = Sqrt(i) 'Uses math law to make the number smaller. Forgot how the operation is called T_T
For a As Integer = 2 To MySqrt
If i Mod a = 0 Then Return False
Label9.Text = a
Next
Return True
End FunctionUsage:
Code:
For i As Double = NumericUpDown2.Value To NumericUpDown1.Value 'From what number to what number
If IsPrimeNumber(i) Then ListBox1.Items.Add(i) 'Adds prime numbers
NextNOTE: Yes, I did get the bonus
Staff will never ever ask you for your personal information.
We know everything about you anyway.
We know everything about you anyway.



![[+]](https://sinister.li/images/modern/collapse_collapsed.png)