- '*************************************************
- '* NOM : IsNPremier
- '* DATE : 31/07/2000
- '*
- '* AUTEUR : Legay Thomas (TomAmplius)
- '*
- '* DESCRIPTION :
- '* Verifie si un nombre est premier
- '*
- '*************************************************
- Option Explicit
- Dim Nombre As Long
- Dim Temp_1 As Long
-
- Private Function IsNpremier(ByRef Nombre As Long) As Boolean
- If Nombre Mod 2 = 0 And Nombre <> 2 Then GoTo Non
- 'ajouter la ligne ci-dessous dans le cas ou les nombres traités sont grands
- '(if right(str(Nombre) = "0" or right(str(Nombre) = "5" )and Nombre <> 5 then goto non:
-
- For Temp_1 = 3 To Sqr(Nombre) Step 2
- If Nombre Mod Temp_1 = 0 Then GoTo Non
- Next Temp_1
- IsNpremier = True
- Exit Function
-
- Non:
- IsNpremier = False
- End Function
'*************************************************
'* NOM : IsNPremier
'* DATE : 31/07/2000
'*
'* AUTEUR : Legay Thomas (TomAmplius)
'*
'* DESCRIPTION :
'* Verifie si un nombre est premier
'*
'*************************************************
Option Explicit
Dim Nombre As Long
Dim Temp_1 As Long
Private Function IsNpremier(ByRef Nombre As Long) As Boolean
If Nombre Mod 2 = 0 And Nombre <> 2 Then GoTo Non
'ajouter la ligne ci-dessous dans le cas ou les nombres traités sont grands
'(if right(str(Nombre) = "0" or right(str(Nombre) = "5" )and Nombre <> 5 then goto non:
For Temp_1 = 3 To Sqr(Nombre) Step 2
If Nombre Mod Temp_1 = 0 Then GoTo Non
Next Temp_1
IsNpremier = True
Exit Function
Non:
IsNpremier = False
End Function