Question
Odd Boost
Bob is given an integer N and creates an array A of the first N odd numbers: A = {1, 3, ..., 2 x (N - 1) + 1}.
For each i from 1 to N, he increases Ai (1 - based indexing) by X, where X is the count of numbers from 1 to N that divide i.
After all operations, determine the number of odd numbers in the array.
Input
The first line of the input contains a single integer N.
Output
Print the number of odd numbers that are present in the array after performing all the operations.
Example
Sample Input
4
Sample Output
2
Explanation
Step 1: Generate the first N odd numbers
Given N = 4, the first 4 odd numbers are:
Step 2: Modify each element A[i] (1-based indexing)
For each index i from 1 to N:
After all updates:
Step 5: Count odd numbers
Final Answer:
4
Sample Output
2
Explanation
Step 1: Generate the first N odd numbers
Given N = 4, the first 4 odd numbers are:
A = [1, 3, 5, 7]
Step 2: Modify each element A[i] (1-based indexing)
For each index i from 1 to N:
- Count how many numbers from 1 to N divide i exactly (let’s call this count X)
- Add X to A[i]
- i = 1: Divisors → {1}, so X = 1 → A[1] = 1 + 1 = 2 → even
- i = 2: Divisors → {1, 2}, so X = 2 → A[2] = 3 + 2 = 5 → odd
- i = 3: Divisors → {1, 3}, so X = 2 → A[3] = 5 + 2 = 7 → odd
- i = 4: Divisors → {1, 2, 4}, so X = 3 → A[4] = 7 + 3 = 10 → even
After all updates:
A = [2, 5, 7, 10]
Step 5: Count odd numbers
- Odd numbers: 5 and 7
- Total odd numbers = 2
Final Answer:
2
✅