74 lines
1.2 KiB
Text
74 lines
1.2 KiB
Text
Mainwin 70 40
|
|
Print " First 30 Jacobsthal numbers:"
|
|
c = 0
|
|
ni0 = 0
|
|
ni1 = 1
|
|
P = 1
|
|
Q = -2
|
|
For j = 0 To 29
|
|
c = c + 1
|
|
Print using("#########",ni0),
|
|
If (c Mod 5) = 0 Then Print
|
|
ni0 = P*ni1 - Q*ni0
|
|
t = ni0
|
|
ni0 = ni1
|
|
ni1 = t
|
|
Next
|
|
Print
|
|
|
|
Print " First 30 Jacobsthal-Lucas numbers:"
|
|
c = 0
|
|
ni0 = 2
|
|
ni1 = 1
|
|
For j = 0 To 29
|
|
c = c + 1
|
|
Print using("#########",ni0),
|
|
If (c Mod 5) = 0 Then Print
|
|
ni0 = P*ni1 - Q*ni0
|
|
t = ni0
|
|
ni0 = ni1
|
|
ni1 = t
|
|
Next
|
|
Print
|
|
|
|
Print " First 20 Jacobsthal oblong numbers:"
|
|
c = 0
|
|
ni0 = 0
|
|
ni1 = 1
|
|
For j = 0 To 19
|
|
c = c + 1
|
|
Print using("###########",ni0*ni1),
|
|
If (c Mod 5) = 0 Then Print
|
|
ni0 = P*ni1 - Q*ni0
|
|
t = ni0
|
|
ni0 = ni1
|
|
ni1 = t
|
|
Next
|
|
Print
|
|
|
|
Print " First 10 Jacobsthal primes:"
|
|
c = 0
|
|
ni0 = 0
|
|
ni1 = 1
|
|
Do
|
|
If isPrime(ni0) Then c = c + 1: Print " "; ni0
|
|
ni0 = P*ni1 - Q*ni0
|
|
t = ni0
|
|
ni0 = ni1
|
|
ni1 = t
|
|
Loop Until c = 10
|
|
|
|
END
|
|
|
|
Function isPrime(n)
|
|
If n < 2 Then isPrime = 0: Exit Function
|
|
If n = 2 Then isPrime = 1: Exit Function
|
|
If n Mod 2 = 0 Then isPrime = 0: Exit Function
|
|
For i = 3 To Int(Sqr(n)) Step 2
|
|
If n Mod i = 0 Then
|
|
isPrime = 0
|
|
Exit Function
|
|
End If
|
|
Next i
|
|
isPrime = 1
|
|
End Function
|