Number of Factors from 1 to N
EasyP3Coding
Given an integer n, return an array of length n whose element at index i (0-based) is the number of positive divisors of i + 1. So the array describes the numbers 1 through n.
Example 1
- Input
- n = 10
- Output
- [1,2,2,3,2,4,2,4,3,4]
Example 2
- Input
- n = 1
- Output
- [1]
Example 3
- Input
- n = 2
- Output
- [1,2]
Constraints
- 1 <= n <= 10^5
Hints
Give it a real attempt first. Run shows which examples fail.
Saved automatically
Run checks the 3 visible tests, Submit all 10. ⌘Enter runs, ⌘⇧Enter submits.