File tree Expand file tree Collapse file tree 2 files changed +20
-6
lines changed
main/java/com/thealgorithms/maths
test/java/com/thealgorithms/maths Expand file tree Collapse file tree 2 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -60,12 +60,6 @@ public static int single(int n) {
60
60
} // n / 10 is the number obtainded after removing the digit one by one
61
61
// Sum of digits is stored in the Stack memory and then finally returned
62
62
63
- public static void main (String [] args ) {
64
- Scanner sc = new Scanner (System .in );
65
- System .out .println ("Enter the number : " );
66
- int n = sc .nextInt (); // Taking a number as input from the user
67
- System .out .println ("Digital Root : " + digitalRoot (n )); // Printing the value returned by digitalRoot() method
68
- }
69
63
}
70
64
71
65
/**
Original file line number Diff line number Diff line change
1
+ package com .thealgorithms .maths ;
2
+
3
+ import static org .junit .jupiter .api .Assertions .assertEquals ;
4
+
5
+ import org .junit .jupiter .api .Test ;
6
+
7
+ public class DigitalRootTest {
8
+
9
+ @ Test
10
+ void testDigitalroot () {
11
+
12
+ assertEquals (4 , DigitalRoot .digitalRoot (4 ));
13
+ assertEquals (9 , DigitalRoot .digitalRoot (9 ));
14
+ assertEquals (4 , DigitalRoot .digitalRoot (49 ));
15
+ assertEquals (6 , DigitalRoot .digitalRoot (78 ));
16
+ assertEquals (4 , DigitalRoot .digitalRoot (1228 ));
17
+ assertEquals (5 , DigitalRoot .digitalRoot (71348 ));
18
+
19
+ }
20
+ }
You can’t perform that action at this time.
0 commit comments