Seedling Weeks
Easy · math
Isla runs a small plant nursery. She starts with a single seedling. At the end of every week, each seedling is split into k new seedlings, so the number of seedlings is multiplied by k each week.
She needs at least n seedlings for a big order. Return the number of weeks she has to wait. If she already has enough at the start, that is 0 weeks.
For example, with k = 3 the counts at the end of the weeks are 3, 9, 27, 81 and so on.
Examples
Example 1
Input: n = 20, k = 3
Output: 3
After 2 weeks she has 9 seedlings, which is not enough. After 3 weeks she has 27, which is.
Example 2
Input: n = 8, k = 2
Output: 3
The counts are 2, 4, 8. Exactly 8 is enough.
Example 3
Input: n = 1, k = 5
Output: 0
She already has 1 seedling at the start.
Constraints
- 1 <= n <= 10^12
- 2 <= k <= 10