RosettaCodeData/Task/Jacobsthal-numbers/11l/jacobsthal-numbers.11l
2023-07-01 13:44:08 -04:00

34 lines
703 B
Text
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

F isPrime(n)
L(i) 2 .. Int(n ^ 0.5)
I n % i == 0
R 0B
R 1B
F odd(n)
R n [&] 1 != 0
F jacobsthal(n)
R floori((pow(2.0, n) + odd(n)) / 3)
F jacobsthal_lucas(n)
R Int(pow(2, n) + pow(-1, n))
F jacobsthal_oblong(n)
R Int64(jacobsthal(n)) * jacobsthal(n + 1)
print(First 30 Jacobsthal numbers:)
L(j) 0..29
print(jacobsthal(j), end' )
print("\n\nFirst 30 Jacobsthal-Lucas numbers: ")
L(j) 0..29
print(jacobsthal_lucas(j), end' "\t")
print("\n\nFirst 20 Jacobsthal oblong numbers: ")
L(j) 0..19
print(jacobsthal_oblong(j), end' )
print("\n\nFirst 10 Jacobsthal primes: ")
L(j) 3..32
I isPrime(jacobsthal(j))
print(jacobsthal(j))