Skip to content

Commit 45b97f5

Browse files
committed
Do not error on marker==0
1 parent 6f08c9f commit 45b97f5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/combinatorial.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ pub fn rank(value: usize, k: u8) -> u128 {
3535
// a bad value (0) if value > (128 choose k) and k == 1 or 2
3636
if value as usize >= MARKER_TABLE_SIZE {
3737
let mut marker = MARKER_TABLES[&k][MARKER_TABLE_SIZE - 1];
38-
for _ in 1..(value - MARKER_TABLE_SIZE) {
38+
for _ in 0..(value - MARKER_TABLE_SIZE) {
39+
// next_rank would underflow if we pass 0, we return it instead
40+
if marker == 0 {
41+
return marker;
42+
}
3943
marker = next_rank(marker);
4044
}
4145
marker

0 commit comments

Comments
 (0)