We can define the Divisibility Streak k
of a number n
by finding the smallest non-negative integer k
such that n+k
is not divisible by k+1
.
Challenge
In your language of choice, write a program or function that outputs or returns the Divisibility Streak of your input.
Examples:
n=13:
13 is divisible by 1
14 is divisible by 2
15 is divisible by 3
16 is divisible by 4
17 is not divisible by 5
The Divisibilty Streak of 13
is 4
n=120:
120 is divisible by 1
121 is not divisible by 2
The Divisibilty Streak of 120
is 1
Test Cases:
n DS
2 1
3 2
4 1
5 2
6 1
7 3
8 1
9 2
10 1
2521 10
More test cases can be found here.
Notes
- Based on Project Euler Problem 601
- This sequence can be found on OEIS, shifted down by 1.
Rules
- You can assume the input is greater than 1.
Scoring
code-golf:The submission with the lowest score wins.
k + 1
is 2, wherek
is the smallest positive integer. Sorry for the nitpick. \$\endgroup\$k
which doesn't dividen-1
? \$\endgroup\$n=7
wherek=3
:n-1
is divisible byk
. \$\endgroup\$+1
. \$\endgroup\$