Added program to check Smith number (#6955)

added smith number program
This commit is contained in:
Taranjeet Singh Kalsi
2025-11-15 15:02:06 +05:30
committed by GitHub
parent 8a339ef2e2
commit 98eecb9f16
2 changed files with 74 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
package com.thealgorithms.maths;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
class SmithNumberTest {
@ParameterizedTest
@CsvSource({"4", "22", "121", "562", "985", "4937775"})
void positiveSmithNumbersTest(int n) {
assertTrue(SmithNumber.isSmithNumber(n));
}
@ParameterizedTest
@CsvSource({"2", "11", "100", "550", "999", "1234557"})
void negativeSmithNumbersTest(int n) {
assertFalse(SmithNumber.isSmithNumber(n));
}
}