primechecker
prime number || not? Interesting: The fastest possibility 2 find out is not the recursive one!
AI
สรุปโดย AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
ซอร์สโค้ด
'1 : as recursive function Function IsPrime(Num As Long, Optional Start As Long = 3) As Boolean If Num Mod 2 <> 0 Then If Num Mod Start <> 0 Then If Start > Sqr(Num) Then _ IsPrime = True Else _ IsPrime = IsPrime(Num, Start + 2) End If End If End Function '2 : as standard-function Function IsPrime(Num As Long) As Boolean Dim L As Long If Num Mod 2 <> 0 Then For L = 3 To Sqr(Num) Step 2 If Num Mod L = 0 Then Exit For Next L If L > Sqr(Num) Then IsPrime = True End If End Function 'example how2 call Sub StartAndWrite() Do Me.Tag = Val(Me.Tag) + 1 If IsPrime(Me.Tag) Then Open App.Path & "\primes.dat" For Append As #1 Print #1, val(Me.Tag) & ","; Close #1 DoEvents End If Loop End Sub
ความคิดเห็นดั้งเดิม (3)
กู้คืนจาก Wayback Machine