RosettaCodeData/Task/Jacobsthal-numbers/00-TASK.txt

50 lines
2.0 KiB
Plaintext
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.

'''Jacobsthal numbers''' are an integer sequence related to Fibonacci numbers. Similar to Fibonacci, where each term is the sum of the previous two terms, each term is the sum of the previous, plus twice the one before that. Traditionally the sequence starts with the given terms 0, 1.
<span style="font-size:125%;font-weight:bold;">
J<sub>0</sub> = 0
J<sub>1</sub> = 1
J<sub>n</sub> = J<sub>n-1</sub> + 2 × J<sub>n-2</sub>
</span>
Terms may be calculated directly using one of several possible formulas:
<span style="font-size:125%;font-weight:bold;">
J<sub>n</sub> = ( 2<sup>n</sup> - (-1)<sup>n</sup> ) / 3
</span>
'''Jacobsthal-Lucas numbers''' are very similar. They have the same recurrence relationship, the only difference is an initial starting value '''J<sub>0</sub> = 2''' rather than '''J<sub>0</sub> = 0'''.
Terms may be calculated directly using one of several possible formulas:
<span style="font-size:125%;font-weight:bold;">
JL<sub>n</sub> = 2<sup>n</sup> + (-1)<sup>n</sup>
</span>
'''Jacobsthal oblong numbers''' is the sequence obtained from multiplying each '''Jacobsthal number''' '''J<sub>n</sub>''' by its direct successor '''J<sub>n+1</sub>'''.
'''Jacobsthal primes''' are '''Jacobsthal numbers''' that are prime.
;Task
* Find and display the first 30 '''Jacobsthal numbers'''
* Find and display the first 30 '''Jacobsthal-Lucas numbers'''
* Find and display the first 20 '''Jacobsthal oblong numbers'''
* Find and display at least the first 10 '''Jacobsthal primes'''
;See also
;* [[wp:Jacobsthal_number|Wikipedia: Jacobsthal number]]
;* [https://www.numbersaplenty.com/set/Jacobsthal_number Numbers Aplenty - Jacobsthal number]
;* [[oeis:A001045|OEIS:A001045 - Jacobsthal sequence (or Jacobsthal numbers)]]
;* [[oeis:A014551|OEIS:A014551 - Jacobsthal-Lucas numbers.]]
;* [[oeis:A084175|OEIS:A084175 - Jacobsthal oblong numbers]]
;* [[oeis:A049883|OEIS:A049883 - Primes in the Jacobsthal sequence]]
;* [[Fibonacci sequence|Related task: Fibonacci sequence]]
;* [[Leonardo numbers|Related task: Leonardo numbers]]