Skip to content
Onsite

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

Run checks the 3 visible tests, Submit all 10.