944,105 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 12465
  • VB.NET RSS
Nov 2nd, 2006
0

Prime Number Function

Expand Post »
I'm trying to write a function that checks for prime numbers and returns true if a number is prime. Something simple, i'm just a beginner. Here's what I have, does it make sense..if not any input would be appreciated.

Function IsPrime(ByVal dblCheck AsDouble) AsBoolean
Dim intNumber As Integer
For intNumber = 2 To dblCheck - 1
If dblCheck Mod intNumber = 0 Then
IsPrime = False
Exit Function
End If
Next intNumber
IsPrime = True
'return prime numbers
Return dblCheck
End Function 'IsPrime
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
geo039 is offline Offline
8 posts
since Nov 2006
Nov 2nd, 2006
0

Re: Prime Number Function

Click to Expand / Collapse  Quote originally posted by geo039 ...
I'm trying to write a function that checks for prime numbers and returns true if a number is prime. Something simple, i'm just a beginner. Here's what I have, does it make sense..if not any input would be appreciated.

Function IsPrime(ByVal dblCheck AsDouble) AsBoolean
Dim intNumber As Integer
For intNumber = 2 To dblCheck - 1
If dblCheck Mod intNumber = 0 Then
IsPrime = False
Exit Function
End If
Next intNumber
IsPrime = True
'return prime numbers
Return dblCheck
End Function 'IsPrime
Try google prime number algorithms
Featured Poster
Reputation Points: 1536
Solved Threads: 431
Posting Expert
iamthwee is offline Offline
5,865 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: guys i really need your help in this one
Next Thread in VB.NET Forum Timeline: how to connect access with vb.net





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC