Skip to content

Latest commit

 

History

History
17 lines (13 loc) · 439 Bytes

File metadata and controls

17 lines (13 loc) · 439 Bytes

Consider a sequence where the first two numbers are 0 and 1 and the next number of the sequence is the sum of the previous 2 modulo 3. Write a function that finds the nth number of the sequence.

Constraints:

  • 1 ≤ N ≤ 10^19

Example:

sequence(1);
0
sequence(2);
1
sequence(3);
1