**In Java please**
As you know, the “mod” operator (%) gives you the remainder from an integer division operation, for example, 25 % 10 is 5. Suppose you have a repeating sequence of numbers like this:
1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, 1, 2, 3, 4, 5, 6, 0, …
Write a line of code that determines the one millionth number in this sequence.
Hint: First look at a simpler question such as, what’s the 20th number in the sequence? And what’s the value of 20 % 7 ? How about the 25th number?
Expert Answer
Answer: 1000000 % 10 is 0
Belowis a line of code that determines the one millionth number in this sequence. The value is 0.
int remainder = 1000000 % 10;
Since we are using divisor 10 here, any value that ends up with 0 will give remainder 0. So in our case, mod % operator will give value 0