26 lines
721 B
Text
26 lines
721 B
Text
Function isPrime(Byval ValorEval As Integer) As Boolean
|
|
If ValorEval <=1 Then Return False
|
|
For i As Integer = 2 To Int(Sqr(ValorEval))
|
|
If ValorEval Mod i = 0 Then Return False
|
|
Next i
|
|
Return True
|
|
End Function
|
|
|
|
Function paresDePrimos(limite As Uinteger) As Uinteger
|
|
Dim As Uinteger p1 = 0, p2 = 1, p3 = 1, count = 0
|
|
For i As Uinteger = 5 To limite
|
|
p3 = p2
|
|
p2 = p1
|
|
p1 = isPrime(i)
|
|
If (p3 And p1) Then count += 1
|
|
Next i
|
|
Return count
|
|
End Function
|
|
|
|
Dim As Uinteger n = 1
|
|
For i As Byte = 1 To 6
|
|
n *= 10
|
|
Print Using "pares de primos gemelos por debajo de < ####### : ####"; n; paresDePrimos(n)
|
|
Next i
|
|
Print !"\n--- terminado, pulsa RETURN---"
|
|
Sleep
|