text: Create a map to store already seen remainders . Remainder is used as key and its position in result is stored as value . Note that we need position for cases like 1 / 6. In this case , the recurring sequence doesn 't  start from first remainder.
code: HashMap < Integer , Integer > mp = new HashMap < > ( ) ; mp . clear ( ) ;