mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-05 16:27:33 +08:00
Add More Tests (#4148)
This commit is contained in:

committed by
GitHub

parent
f35e9a7d81
commit
7779c18ef6
@ -5,22 +5,12 @@ package com.thealgorithms.maths;
|
||||
*/
|
||||
public class LucasSeries {
|
||||
|
||||
public static void main(String[] args) {
|
||||
assert lucasSeries(1) == 2 && lucasSeriesIteration(1) == 2;
|
||||
assert lucasSeries(2) == 1 && lucasSeriesIteration(2) == 1;
|
||||
assert lucasSeries(3) == 3 && lucasSeriesIteration(3) == 3;
|
||||
assert lucasSeries(4) == 4 && lucasSeriesIteration(4) == 4;
|
||||
assert lucasSeries(5) == 7 && lucasSeriesIteration(5) == 7;
|
||||
assert lucasSeries(6) == 11 && lucasSeriesIteration(6) == 11;
|
||||
assert lucasSeries(11) == 123 && lucasSeriesIteration(11) == 123;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate nth number of lucas series(2, 1, 3, 4, 7, 11, 18, 29, 47, 76,
|
||||
* Calculate nth number of Lucas Series(2, 1, 3, 4, 7, 11, 18, 29, 47, 76,
|
||||
* 123, ....) using recursion
|
||||
*
|
||||
* @param n nth
|
||||
* @return nth number of lucas series
|
||||
* @return nth number of Lucas Series
|
||||
*/
|
||||
public static int lucasSeries(int n) {
|
||||
return n == 1
|
||||
@ -29,7 +19,7 @@ public class LucasSeries {
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate nth number of lucas series(2, 1, 3, 4, 7, 11, 18, 29, 47, 76,
|
||||
* Calculate nth number of Lucas Series(2, 1, 3, 4, 7, 11, 18, 29, 47, 76,
|
||||
* 123, ....) using iteration
|
||||
*
|
||||
* @param n nth
|
||||
|
Reference in New Issue
Block a user