[Question]
  [
Sometimes to fall asleep, I'll count as high as I can, whilst skipping numbers that are not [square-free](https://en.wikipedia.org/wiki/Square-free_integer). I get a little thrill when I get to skip over several numbers in a row - for example, `48,49,50` are all NOT square-free (48 is divisible by 2^2, 49 by 7^2, and 50 by 5^2).
This led me to wondering about the earliest example of adjacent numbers divisible by some arbitrary sequence of divisors.
## Input
Input is an ordered list `a = [a_0, a_1, ...]` of strictly positive integers containing at least 1 element.
## Output
Output is the smallest positive integer `n` with the property that `a_0` divides `n`, `a_1` divides `n+1`, and more generally `a_k` divides `n+k`. If no such `n` exists, the function/program's behavior is not defined.
## Test Cases
```
[15] -> 15
[3,4,5] -> 3
[5,4,3] -> 55
[2,3,5,7] -> 158
[4,9,25,49] -> 29348
[11,7,5,3,2] -> 1518
```
## Scoring
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"); shortest result (per language) wins bragging rights. The usual loopholes are excluded.
  
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 51 bytes
```
Mod[ChineseRemainder[1-Range@Length@#,#],LCM@@#,1]&
```
[Try it online!](https://tio.run/##FcmxCoMwGEXhV/kx4HSlxCji0BJwVSiuIUOoUTOYgs0mPnuabN/hHCbs9jDBfUxc6Ulx@i5q2J23Pzun4fxiT8Wr2fjNytH6LeySgWmMwySTuC7j@3Q@KAYqqHpRAVoV05pKeki6LoEG7Q262gSRUUOgRZfZoEedRp@Dc3RpCNS5xH3HPw "Wolfram Language (Mathematica) – Try It Online")
[Answer]
# [Husk](https://github.com/barbuz/Husk), 7 bytes
```
VδΛ¦⁰ṫN
```
[Try it online!](https://tio.run/##yygtzv6vkKtR/KipsUjz0Lb/Yee2nJt9aNmjxg0Pd672@///f7SxjomOaSxXtCmQNgbSRjrGOqY65kCWiY6ljhFQ2BLINjTUMQcKG@sYxQIA "Husk – Try It Online")
## Explanation
```
VδΛ¦⁰ṫN  Input is a list x.
      N  The list [1,2,3...
     ṫ   Tails: [[1,2,3...],[2,3,4...],[3,4,5...]...
V        Index of first tail y satisfying this:
  Λ       Every element
    ⁰     of x
   ¦      divides
 δ        the corresponding element of y.
```
[Answer]
# [MATL](https://github.com/lmendo/MATL), 11 bytes
```
`Gf@q+G\a}@
```
[Try it online!](https://tio.run/##y00syfn/P8E9zaFQ2z0msdbh//9oUx0THeNYAA "MATL – Try It Online")
```
`           % Do ....
 Gf         %   Convert input to [1,2,...,]
   @q+      %   Add current iteration index minus one, to get [n, n+1, ....]
      G\    %   Elementwise mod([n,n+1,...],[a_0,a_1,...])
        a   % ...while any of the modular remainders is nonzero.
         }  % Finally:
          @ %   Output the iteration index.
```
Not exactly optimized for speed... the largest testcase takes a full minute using MATL, and approximately 0.03s on MATLAB. There is a small possibility MATL has a bit more overhead.
[Answer]
# JavaScript, ~~42~~ 40 bytes
Will throw a recursion error if there is no solution (or the solution is too big).
```
a=>(g=y=>a.some(x=>y++%x)?g(++n):n)(n=1)
```
Saved 2 bytes with a pointer from [Rick Hitchcock](https://codegolf.stackexchange.com/users/42260/rick-hitchcock)
---
## Try it
Enter a comma separated list of numbers.
```
o.innerText=(f=
a=>(g=y=>a.some(x=>y++%x)?g(++n):n)(n=1)
)(i.value=[5,4,3]);oninput=_=>o.innerText=f(i.value.split`,`.map(eval))
```
```
<input id=i><pre id=o>
```
[Answer]
# [Python 3](https://docs.python.org/3/), 62 bytes
```
f=lambda x,n=1:all(j%k<1for j,k in enumerate(x,n))or-~f(x,n+1)
```
[Try it online!](https://tio.run/##VY1PS8MwGMbv/RSvB1nTvT2kWTdWnCCCUNQdZi8yxqgzxWxtUpIUOsb86jWpB/H2e/7xtGf7pSQbKq0a0NyoTh84iKZV2kIUjLY5mz8nMNzqWjTChpuX/DUv9m/Fw@Mzwij3@fopX@fFO8I/Sci444dOG6Hk7z6JIkYhBkqGalWXzcdnCT3KFc3Kug6Pt6c7WikNRzyBkMBl13BdWh66DiFKx9@Vx6mfu1rvS9vFDmHLcIaph9QB85AgwxTHcIZLTFyw9IJSXLiAYbLLAoBWC2nDanLpb0xG51eI7@HiXkiWXidk@AE "Python 3 – Try It Online")
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E), 9 bytes
```
Xµā<N+sÖP
```
[Try it online!](https://tio.run/##MzBNTDJM/f8/4tDWI402ftrFh6cF/P8fbWioY65jqmOsYxQLAA "05AB1E – Try It Online")
**Explanation**
```
Xµ          # loop until counter equals 1
  ā         # push range [1 ... len(input)]
   <        # decrement
    N+      # add current iteration index N (starts at 1)
      sÖ    # elementwise evenly divisible by
        P   # product
            # if true, increase counter
            # output N
```
[Answer]
# [Haskell](https://www.haskell.org/), ~~45~~ 44 bytes
```
f a=[n|n<-[1..],1>sum(zipWith mod[n..]a)]!!0
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/P00h0TY6rybPRjfaUE8vVsfQrrg0V6MqsyA8syRDITc/JToPKJyoGauoaPA/NzEzz7agKDOvRCUt2lTHRMc49j8A "Haskell – Try It Online")
*Edit: -1 byte thanks to nimi!*
[Answer]
# [Clean](https://clean.cs.ru.nl), 61 bytes
```
import StdEnv
$l=hd[n\\n<-[1..]|and[i/e*e==i\\i<-[n..]&e<-l]]
```
[Try it online!](https://tio.run/##DcuxCsIwEADQ3a/IUBwkqSh1KDSbHQS3jkmGI4l6kFyljYLgt3tmffB8ikCc5/BKUWRAYszPeSliKmGk96ZJ@hEMWUuDMoe2dV@gYHAfd1FrtBYrU@VtHFRyjqcCNWvRCNPJXh5Psusd//wtwX1ldbny@UOQ0a9/ "Clean – Try It Online")
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 11 bytes
```
f!s.e%+kTbQ 
```
[Try it online!](https://tio.run/##K6gsyfj/P02xWC9VVTs7JCnw//9oEx1LHSNTHRPLWAA "Pyth – Try It Online")
---
```
f!s.e%+kTbQ         Full program - inputs list from stdin and outputs to stdout
f                   First number T such that
   .e     Q         The enumerated mapping over the Input Q
      +kT           by the function (elem_value+T)
     %   b          mod (elem_index)
 !s                 has a false sum, i.e. has all elements 0
```
[Answer]
# [J](http://jsoftware.com/), 23 bytes
```
[:I.0=]+/@:|"1#]\[:i.*/
```
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/o6089QxsY7X1HaxqlAyVY2OirTL1tPT/a3IpcKUmZ@QrpCkYK5gomMI4pkCOMYxjBJQzVTCHcU0ULBWMgAosYQKGhgrmQAXGCkb/AQ "J – Try It Online")
[Answer]
# [R](https://www.r-project.org/), 51 bytes
```
function(l){while(any((F+1:sum(l|1))%%l))F=F+1
F+1}
```
[Try it online!](https://tio.run/##K/qfpmCj@z@tNC@5JDM/TyNHs7o8IzMnVSMxr1JDw03b0Kq4NFcjp8ZQU1NVNUdT080WKMYFxLX/0zSSNUx0LHWMTHVMLDU1/wMA "R – Try It Online")
The use of `any` throws `k` warnings about implicit conversion to `logical`, where `k` is the return value.
[Answer]
# [Perl 6](http://perl6.org/), 34 bytes
```
->\a{first {all ($_..*)Z%%a},^∞}
```
[Try it online!](https://tio.run/##FclRCoMgAIfxq/wJGzVakOYiVh5kROJDQmA0bC8hvu8UO9wu4vTt9/G9FmvuYTtx0RjDTUzK6dUebzhlDAoi6/paPvNc@Wr@fb4@HOpERiRGAadBpM@gd4uBoQUXFQYewRIoGDi6xBY9aBx9iqZBFwcDFY/wBw "Perl 6 – Try It Online")
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), ~~24 23~~ 22 bytes
```
{∨/×⍺|⍵+⍳⍴⍺:⍺∇⍵+1⋄⍵}∘1
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///qG@qp/@jtgkG/9OAZPWjjhX6h6c/6t1V86h3q/aj3s2POhcBeVZA/KijHSRm@Ki7BUjXPuqYYfj/f5qCsYKJgilXmoIpkDYG0kZAEVMFcyDLRMFSwQgobAlkGxoqmAOFjRWMAA "APL (Dyalog Unicode) – Try It Online")
Technically, this is a tacit function. I had to make it so since the only input allowed is the list of integers. Uses `⎕IO←0` (0-indexing)
It's worth noting that the function times out if `n` doesn't exist.
Thanks to @ngn and @H.PWiz for 1 byte each.
### How?
```
{∨/×⍺|⍵+⍳≢⍺:⍺∇⍵+1⋄⍵}∘1 ⍝ Main function. ⍺=input; ⍵=1.
{                   }∘1 ⍝ Using 1 as right argument and input as left argument:
           :            ⍝ If
        ⍳≢⍺             ⍝ The range [0..length(⍺)]
      ⍵+                ⍝ +⍵ (this generates the vector ⍵+0, ⍵+1,..., ⍵+length(⍺))
    ⍺|                  ⍝ Modulo ⍺
   ×                    ⍝ Signum; returns 1 for positive integers, ¯1 for negative and 0 for 0.
 ∨/                     ⍝ Logical OR reduction. Yields falsy iff the elements of the previous vector are all falsy.
            ⍺∇⍵+1       ⍝ Call the function recursively with ⍵+1.
                 ⋄⍵     ⍝ Else return ⍵.
```
[Answer]
# [Perl 5](https://www.perl.org/), 49 + 2 (`-pa`) = 51 bytes
```
$i=!++$\;($\+$i)%$_&&last,$i++for@F;$i<@F&&redo}{
```
[Try it online!](https://tio.run/##K0gtyjH9/18l01ZRW1slxlpDJUZbJVNTVSVeTS0nsbhERyVTWzstv8jBzVol08bBTU2tKDUlv7b6/38TBUsFI1MFE8t/@QUlmfl5xf91fU31DAwN/usWJAIA "Perl 5 – Try It Online")
[Answer]
# Japt, 10 bytes
Will eventually output `undefined` if no solution exists, if it doesn't crash your browser first.
```
@e_X°vZÃ}a
```
[Try it](https://ethproductions.github.io/japt/?v=1.4.5&code=QGVfWLB2WsN9YQ==&input=WzUsNCwzXQ==)
---
## Explanation
```
               :Implicit input of array U
@       }a     :Loop and output the first integer X that returns true.
 e_    Ã       :For every element Z in U
   X°          :X, postfix increcemnted
     vZ        :Is it divisible by Z?
```
[Answer]
# [Ruby](https://www.ruby-lang.org/), 48 bytes
```
->l{1+(1..1/0.0).find{|x|l.all?{|y|(x+=1)%y<1}}}
```
[Try it online!](https://tio.run/##FclBCsIwEEDRfU/RjdDScewkDaVg9SAhi4oEhFGKIDRkcvaY7N7nf3@PkP2azzeONHSESJcRxx796/OMcgjjxnyPEqQ7hpX6U7hSSilbq2EC46C1pkBXKNBgYK6cYAFVxlKDCOYyNCjn8L3tUViavbUM3rJzTcp/ "Ruby – Try It Online")
[Answer]
# [Python 2](https://docs.python.org/2/), 80 bytes
```
def f(l,n=1):
 while n:
	n+=1
	if all((n+i)%v<1for i,v in enumerate(l)):return n
```
[Try it online!](https://tio.run/##FY7BCoQgFEXX@RVvM6D0NmoSSX1JtAhGSXBeIdYwX@/o7lzOXZzrl4@TVClv58HziLRIYRl8jxAdkGUd9YtkXfCwx8g59UG8nln6M0HABwKBo/vj0p4dj0LY5PKdCKi0R25@1Tig2RBWU0E3UKjR4NhwwAlVFVMbUuJYhUa11Qa4UqBcq7Iofw "Python 2 – Try It Online")
[Answer]
# [Standard ML (MLton)](http://www.mlton.org/), 96 bytes
```
open List;fun$n% =if all hd(tabulate(length%,fn i=>[1>(n+i)mod nth(%,i)]))then n else$(n+1)%;$1;
```
[Try it online!](https://tio.run/##PYzBasMwEETv@oo92CClm4Isi8QI@x7orUdhiktkWyCvQ73J77tKKL3Nm3nMtqTjknilfV9vgeAjbuzGOxVUQhtHGFKC@Sp5@L6ngYNMgSaeSxwJYtt53Ul6i2pZr0A8yxKj6pXiOT8RhLSFIu9ala7Qbn8MCSZoIbITz/yV8@0nEoO8EL/z@smZJpAT@AoNWjz1CpQT8iC8wRptD8cOjPA2g3mBteLffbK2Z@FrbLDKTvOqqsbUudQaT1kzWP2J@iwOav8F "Standard ML (MLton) – Try It Online")
### Ungolfed:
```
open List
fun f n l = 
    if all (fn x=>x)
           (tabulate ( length l
                     , fn i => (n+i) mod nth(l,i) = 0))
    then n 
    else f (n+1) l
val g = f 1
```
[Try it online!](https://tio.run/##TY47b8MwDIR3/YobpZQJKitC4sHeC3TraASFi/oFyHRQM0X@vcs4QdubeMePj3lM2zHJxMsynRvG6zCLaS@MFoyEAgaqoUWdEmzLuBbl1a3hQ1bqj0uqpYFFariTHul//08EnR9QlLD8NDiM0ydYeptITYFnd98rvf7B98NNmht9RXnvdO13ndAp2sIvt/pd6/PXwAL7wrKT6U3UdbAdqowCRTqcHJyxG1MF2lM8YVsimCqqCauJ0fyiN@/j0VR7yilTJl@jLA97Db2ng2KBsgfoj2bjlh8 "Standard ML (MLton) – Try It Online") Starting with `n=1`, the function `f` increments `n` until the `all`-condition is fulfilled, in which case `n` is returned.
`tabulate(m,g)` with some integer `m` and function `g` builds the list `[g 0, g 1, ..., g m]`. In our condition `tabulate` is called with the length of the input list `l` and a function which checks whether the `i`th element of `l` divides `n+i`. This yields a list of booleans, so `all` with the identity function `fn x=>x` checks whether all elements are true.
I found a nice golfing trick to shorten the identity function in this case by four bytes: Instead of the lambda `(fn x=>x)`, the build-in function `hd` is used, which returns the first element of a list, and the resulting bools in `tabulate` are wrapped in `[` and `]` to create singleton lists.
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), ~~65~~ 62 bytes
```
for(){$o=1;$i=++$j;$args[0]|%{$o*=!($i++%$_)};if($o){$j;exit}}
```
[Try it online!](https://tio.run/##K8gvTy0qzkjNyfn/Py2/SEOzWiXf1tBaJdNWW1sly1olsSi9ONogtkYVKK5lq6ihkqmtraoSr1lrnZmmoZIPVJ5lnVqRWVJb@///fwcNQ0Mdcx1THWMdI00A "PowerShell – Try It Online")
PowerShell doesn't have the equivalent of an `any` or `some` or the like, so we need a slightly different approach.
This takes input `$args[0]` as an array, then enters an infinite `for` loop. Each iteration we set `$o` to be `1` (explained later), and set `$i` to be `++$j`. The incrementing `$j` keeps tabs on what the first number of the proposed solution is, while the `$i` will increment over the rest of the proposed solution.
We then send each element of the input `$args[0]` into a `ForEach-Object` loop. Inside the inner loop, we Boolean-multiply into `$o` the result of a calculation. This will make it so that if the calculation fails for a value, the `$o` will turn to `0`. The calculation is `!($i++%$_)`, or the Boolean-not of the modulo operation. Since any nonzero value is truthy in PowerShell, this turns any remainders into a falsey value, thus turning `$o` into `0`.
Outside the inner loop, `if` `$o` is nonzero, we've found an incrementing solution that works, so we output `$j` and `exit`.
[Answer]
# [tinylisp](https://github.com/dloscutoff/Esolangs/tree/master/tinylisp), 108 bytes
```
(load library
(d ?(q((L N)(i L(i(mod N(h L))0(?(t L)(inc N)))1
(d S(q((L N)(i(? L N)N(S L(inc N
(q((L)(S L 1
```
The last line is an unnamed lambda function that takes a list and returns an integer. [Try it online!](https://tio.run/##RY07DoNADAX7nOKVz12WDaLkAoiGE2yyQrHEPzScfmOnSfVG1ox86nJN@tlK4bSmjEmfRzquGzNa7mSHXqjoqJzXjJ5vdCJ3tjwNqMvLBJHgwfAP2MKh5@CpSy6MP0H8iFA4pw0juIMMtYARD/jWttG2QkSNxigENIYRlf2S8gU "tinylisp – Try It Online")
### Ungolfed
```
(load library)
(comment Function to check a candidate n)
(def sequentially-divisible?
 (lambda (divisors start-num)
  (if divisors
   (if (divides? (head divisors) start-num)
    (sequentially-divisible? (tail divisors) (inc start-num))
    0)
   1)))
(comment Function to check successive candidates for n until one works)
(def search
 (lambda (divisors start-num)
  (if (sequentially-divisible? divisors start-num)
   start-num
   (search divisors (inc start-num)))))
(comment Solution function: search for candidates for n starting from 1)
(def f
 (lambda (divisors)
  (search divisors 1)))
```
[Answer]
# [Julia 0.6](http://julialang.org/), 79 bytes
```
f(s,l=length(s),n=s[])=(while !all(mod.(collect(0:l-1).+n,s).==0);n+=s[];end;n)
```
[Try it online!](https://tio.run/##XctBDoIwEIXhvafQ3UwYG0pBgqQnISwIFMGMg7EYj1/rznT7vf/d37wOlxBm8MSWndz2BTySWN/1aOGzrOyOp4EZHtukYNyY3bhDfuWzRpUJeVTW5thK9ru0TqZWMDxfq@wsMEOnqx7x8AeGSkqtimYSK8hQRXWiJTVUxLxJXGuqY26oiEP4Ag "Julia 0.6 – Try It Online")
Inputs without valid solutiosn will cause infinite looping... :)
[Answer]
# Python 2, 78 bytes
```
def f(a,c=0):
 while [j for i,j in enumerate(a) if(c+i)%j<1]!=a:c+=1
 return c
```
EDIT: -26 thanks to @Chas Brown
[Answer]
# [Ruby](https://www.ruby-lang.org/), ~~47 46 43~~ 42 bytes
```
->a{(1..).find{|i|a.all?{|v|i%v<1&&i+=1}}}
```
[Try it online!](https://tio.run/##XcxLCsIwFIXhuasoFYviNXBzE2rA6kJqBxENBIoU@wBJsvYYigPr@PvPeY23dzTVNR7O2iHrh0fHjH3enbdeM922F@cnbzfTCYvC7isMIcRuHPosXztT1wQCZNOEbEu7fPUDMgHNIOVSOBBIKGdDeVyiAAU8bdXMXJH4CxChTHMC/j3AFMQP "Ruby – Try It Online")
NB: the `(1..)` syntax is only supported in ruby 2.6, for the moment TIO only supports 2.5 so the link is to an older version (43 bytes).
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 10 bytes
```
1Ḷ+$ọ¥Ạ¥1#
```
[Try it online!](https://tio.run/##ASUA2v9qZWxsef//MeG4tisk4buNwqXhuqDCpTEj////WzUsIDQsIDNd "Jelly – Try It Online")
[Answer]
# APL NARS, 140 bytes, 70 chars
```
r←f w;i;k
i←r←1⊃,w⋄k←¯1+⍴w⋄→0×⍳k=0
A:→0×⍳0=+/(1↓w)∣(k⍴r)+⍳k⋄r+←i⋄→A
```
test
```
  f 15
15
  f 3 4 5
3
  f 5 4 3
55
  f 2 3 5 7
158
  f 4 9 25 49
29348
  f 11 7 5 3 2 
1518
```
[Answer]
# Java 8, ~~82~~ 75 bytes
```
a->{for(int r=1,i,f;;r++){i=f=0;for(int b:a)f+=(r+i++)%b;if(f<1)return r;}}
```
**Explanation:**
[Try it online.](https://tio.run/##lY7BbsIwEETvfMVeKtnKEpGECFGT/kG5cEQcnGAj0@BEjkNVRf72dAn0nkrrlbwzozdXeZfLplX2ev4aq1p2HXxKY4cFgLFeOS0rBfvHdzpAxWgfTyC5oFugR9N56U0Fe7BQwCiXH4Nu3MMIrkjQoBbCRREfTKGLlfjTynfJdVQwFxkS30phNNO7hDvle2fBiRBG8QS0fVkT4MW5N@YMN2rJDt4ZezmeJH82PPx0Xt3ipvdxS4qvLbNxxaz6hqn2kOSBT81neDNc4z/sOdmz@fYUM8xxMz@wxi2mBNnOjyQJbgiSYfrKhEUYfwE)
```
a->{                 // Method with integer-array parameter and integer return-type
  for(int r=1,       //  Return-integer, starting at 1
          i,         //  Index-integer
          f;         //  Flag-integer
      ;r++){         //  Loop indefinitely, increasing `r` by 1 after every iteration
    i=f=0;           //   Reset both `i` and `f` to 0
    for(int b:a)     //   Inner loop over the input-array
      f+=(r+i++)%b;  //    Increase the flag-integer by `r+i` modulo the current item
    if(f<1)          //   If the flag-integer is still 0 at the end of the inner loop
      return r;}}    //    Return `r` as result
```
]