Skip to content

Commit 5d94423

Browse files
author
WinterPancake
committed
Implemented BigUint
1 parent 15c3a04 commit 5d94423

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/math/triangular_number.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Triangular Numbers: Function to the Nth Triangular Number
22
// Wikipedia Reference : https://en.wikipedia.org/wiki/Triangular_number
3-
4-
pub fn triangular_number(n: u64) -> u64 {
5-
let m: u64 = (n | 1) * ((n + 1) / 2);
3+
use num_bigint::BigUint;
4+
pub fn triangular_number(n: u64) -> BigUint {
5+
let m: BigUint = ((n | 1) * ((n + 1) / 2)).into();
66
m
77
}
88

@@ -23,8 +23,8 @@ mod tests {
2323
}
2424

2525
test_triangular_number! {
26-
input_5: (6, 21),
27-
input_9: (10, 55),
28-
input_10: (100, 5050),
26+
input_5: (6, BigUint::from(21u32)),
27+
input_9: (10, BigUint::from(55u32)),
28+
input_10: (100, BigUint::from(5050u32)),
2929
}
3030
}

0 commit comments

Comments
 (0)