Skip to content

Practice Number of Distinct Roll Sequences

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Hard#2318
LeetCode Problem

Number of Distinct Roll Sequences

Problem Statement

Count length-n sequences of rolls with values 1 through 6. Every adjacent pair must have greatest common divisor 1, and any two equal values must have indices more than 2 apart. Sequences differing at any position are distinct. Return the count modulo 10^9 + 7.

Source: Number of Distinct Roll Sequences on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
n = 4
Output
184

# Example 2

Input
n = 2
Output
22

Constraints

1 <= n <= 10^4

Related LeetCode Problems

Practice more problems similar to Number of Distinct Roll Sequences.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.