Add BigInteger to karprekar number (#2899)

Co-authored-by: Andrii Siriak <siryaka@gmail.com>
This commit is contained in:
Subhro Acharjee
2022-01-13 01:53:53 +05:30
committed by GitHub
parent 2a27d09a17
commit ab9f74c2ee
2 changed files with 36 additions and 11 deletions

View File

@ -1,7 +1,7 @@
package com.thealgorithms.maths;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import static org.junit.jupiter.api.Assertions.*;
public class KaprekarNumbersTest {
@ -55,4 +55,16 @@ public class KaprekarNumbersTest {
assertFalse(KaprekarNumbers.isKaprekarNumber(98));
}
@Test
void testForRangeOfNumber() { try {
ArrayList<Long> rangedNumbers = KaprekarNumbers.kaprekarNumberInRange(1,100000);
long[] allTheNumbers = {1, 9, 45, 55, 99, 297, 703, 999, 2223, 2728, 4950, 5050, 7272, 7777, 9999, 17344, 22222, 77778, 82656, 95121, 99999};
for (long i:allTheNumbers) {
assert rangedNumbers.contains(i);
}
} catch (Exception e) {
assert false;
}
}
}