# Divisibility Streak

## Java 8, ~~44~~ ~~42~~ ~~41~~ 39 bytes

^{Crossed out 44 is still regular 44 ;(}

```
n->{int r=0;for(;~-n%--r<1;);return~r;}
```

-2 bytes thanks to *@LeakyNun*.

-1 byte thanks to *@TheLethalCoder*.

-2 bytes thanks to *@Nevay*.

**Explanation:**

Try it here.

```
n->{ // Method with integer as parameter and return-type
int r=0; // Result-integer (starting at 0)
for(;~-n%--r<1;); // Loop as long as `n-1` is divisible by `r-1`
// (after we've first decreased `r` by 1 every iteration)
return~r; // Return `-r-1` as result integer
} // End of method
```

## Haskell, 35 bytes

```
f n=[k|k<-[1..],rem(n+k)(k+1)>0]!!0
```

Try it online!

Using `until`

is also 35 bytes

```
f n=until(\k->rem(n+k)(k+1)>0)(+1)1
```

## Pyth, ~~6~~ 5 bytes

```
f%tQh
```

Try it online!