Skip to content

Commit

Permalink
59: Re-submit
Browse files Browse the repository at this point in the history
  • Loading branch information
sankichi92 committed Dec 29, 2023
1 parent 16b61fa commit fe7ea67
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion 59-n-th-tribonacci-number/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ pub fn tribonacci(n: i32) -> i32 {
0 => 0,
1 => 1,
2 => 1,
_ => tribonacci(n - 1) + tribonacci(n - 2) + tribonacci(n - 3)
3 => 2,
_ => 2 * tribonacci(n - 1) - tribonacci(n - 4),
}
}

Expand All @@ -20,4 +21,9 @@ mod tests {
fn case2() {
assert_eq!(tribonacci(25), 1389537)
}

#[test]
fn failed_case1() {
assert_eq!(tribonacci(34), 334745777)
}
}

0 comments on commit fe7ea67

Please sign in to comment.