Skip to content

Practice Count the Number of Ideal Arrays

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

Hard#2338
LeetCode Problem

Count the Number of Ideal Arrays

Problem Statement

Count arrays of length n whose entries lie from 1 through maxValue inclusive and whose every entry after the first is divisible by its immediate predecessor. Return the count modulo 10^9 + 7.

Source: Count the Number of Ideal Arrays on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
n = 2, maxValue = 5
Output
10

# Example 2

Input
n = 5, maxValue = 3
Output
11

Constraints

2 <= n <= 10^4
1 <= maxValue <= 10^4

Related LeetCode Problems

Practice more problems similar to Count the Number of Ideal Arrays.

Review your practice with PhantomCodeAI

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