[Question]
  [
Your task is to write a program which given an array and a number, you need to split the array into chunks with size is number.
## Rules
Your program will receive an array `A` , as well as a positive integer `n`. The array should then be split into chunks of length `n`, if the length of the string isn't divisible by `n` any leftover at the end should be considered its own chunk.
* If `n` is greater than length of array `A`, you will need to return array `A`, for example: if `n = 4` and `array A = [1,2,3]`, you should return `[1,2,3]`
* The array can contain any type rather than number.
* You should not change order (or direction) of any item from left to right. For example `if n = 2` and `A= [1,2,3]`. Any result rather than `[[1,2],[3]]` will be invalid.
## Test Cases
```
n   A               Output
2   [1,2,3,4,5,6]   [[1,2],[3,4],[5,6]]
3   [1,2,3,4,5,6]   [[1,2,3],[4,5,6]]
4   [1,2,3,4,5,6]   [[1,2,3,4],[5,6]]
```
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so you the shortest bytes of each language will be the winner.
  
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 1 [byte](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
√¥
```
[Try it online](https://tio.run/##yy9OTMpM/f//8Jb//024og11jHSMdUx0THXMYgE) or [verify all test cases](https://tio.run/##yy9OTMpM/W/mU1Zpr6TwqG2SgpK9Z@X/w1v@6/yPNtQx0jHWMdEx1TGLBQA).
Builtins ftw. :)
[Answer]
# JavaScript (ES6), 36 bytes
Takes input as `(n)(array)`.
```
n=>g=a=>a+a&&[a.splice(0,n),...g(a)]
```
[Try it online!](https://tio.run/##Fcq7CsIwFADQvV9xBykJicH6QqzpBzjo4FgKvcQmRMpNaYogpd8edTrLeeEboxn9MK0pPLtkdSJdOY26QoF5XqOKQ@9NxzaSuFRKOYa8STaMjEBDUQLBBU4/hOAwZwAmUAx9p/rgWPs/q5mWM7Qg4Pq431ScRk/O2w@zjDirC7mVO7mXB3lsOOdltqQv "JavaScript (Node.js) ‚Äì Try It Online")
### Commented
```
n =>                  // n = chunk size
  g = a =>            // g = recursive function taking the array a[]
    a + a             // if a[] is empty, stop recursion and return an empty string
    &&                // otherwise, return an array made of:
    [ a.splice(0, n), //   the next chunk
      ...g(a)         //   followed by the result of a recursive call
    ]                 //   (the last call leads to ...'', which adds nothing)
```
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 12 [bytes](https://codegolf.meta.stackexchange.com/a/9429/43319 "When can APL characters be counted as 1 byte each?")[SBCS](https://github.com/abrudz/SBCS ".dyalog files using a single byte character set")
```
‚ä¢‚äÇ‚ç®(‚ç¥‚ä¢)‚ç¥1‚Üë‚ç®‚ä£
```
Big thanks to [Ad√°m](https://codegolf.stackexchange.com/users/43319/ad%C3%A1m) for basically doing basically all the golfing (and for basically all the APL knowledge I have currently >\_>).
### Explanation
```
 ‚äÇ‚ç®           Partitioned enclose (commuted, i.e. left and right switched) - for each ‚çµ in left, ‚ç∫ in right, if ‚ç∫ = 0, create a new sub-array, push ‚çµ to latest sub-array
‚ä¢             Right argument of entire expression
       ‚ç¥      Reshape - Change size of right into dimensions specified by left
   (‚ç¥ )       Shape of (here, there is only one dimension - length)
     ‚ä¢        Right argument of entire expression
         ‚Üë‚ç®   Take (commuted) - takes ‚ç∫ elements from left where ‚ç∫ is right. Extra elements (zeroes here) are automatically added
        1     1
           ‚ä£  Left argument of entire expression
```
### Execution
Arguments `2`, `1 2 3 4 5 6 7`. Note that APL arrays are of the form `a b c`, with optional surrounding parentheses.
```
           ‚ä£  2
        1     1
         ‚Üë‚ç®   1‚Üë2 = 1 0
     ‚ä¢        1 2 3 4 5 6 7
   (‚ç¥ )       ‚ç¥1 2 3 4 5 6 7 = 7
       ‚ç¥      7‚ç¥1 0 = 1 0 1 0 1 0 1
‚ä¢             1 2 3 4 5 6 7
 ‚äÇ‚ç®           1 0 1 0 1 0 1‚äÇ1 2 3 4 5 6 7 = (1 2)(3 4)(5 6)(7)
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT/@v8ahvql/wo941mnogZrCrXqizr4t6Un6FQn6egm6aLYgssS0pSk1Vf9S1ODUvMSknNdjRJwTIAap3jlQvTswpUdf8/6hr0aOupke9KzQe9W4BcjSBlOGjtolAEaDS/2mP2iY86u0DavH0f9TVfGi9MUgOaGGQM5AM8fAM/g@kgYqMFNIUDBWMFIwVTBRMFcy4IKLGWEVNsIqimaBgjt0MuLgJujgA "APL (Dyalog Unicode) ‚Äì Try It Online")
[Answer]
# [Python 3](https://docs.python.org/3/), 61 bytes
```
lambda A,n:[A,[A[x:x+n]for x in range(0,len(A),n)]][n<len(A)]
```
[Try it online!](https://tio.run/##ZZBNboMwEIXX@BQjJITdulITki6ssmDRRc/gWBUBkyBRg8CR6Ompx5AfWhZPeOab5@fpfuy5NclUpYepyb@PZQ4ZN0JmXGZyFOOzUVXbwwi1gT43J01feaMNzRg3TClp3ueTmqwe7AApSALuo3LDYcsh4bDjsOfwptwf40szzmMO8RGlQClRNEqFckI5o9Sxm0tuczfTlYFDtv@RnSvvmasqQvTY6cLq8qu9LCEDuSalz6g4Nv6ay1U@X1glnKfQDntzOk9dLTzwcB1xkXCt9X2tuEa/QsYECdq0ok/@KGvFSND1tbE0/DRATRqVTBxsNITRlZBCvGweuI/luQtGV89HxzuaFfaSNw5E9GDCqGXTLw "Python 3 ‚Äì Try It Online")
Modifies [Henry T's existing Python 3 solution](https://codegolf.stackexchange.com/a/180979/85755) to produce valid output for n >= len(A).  
Posting as its own answer due to lack of commenting privileges.
[Answer]
# [Prolog (SWI)](http://www.swi-prolog.org), ~~90~~ ~~84~~ 61 bytes
### Code:
```
[]*_*[].
L*N*[P|R]:-length(P,N),append(P,T,L),T*N*R;P=L,R=[].
```
The input format might be a bit weird, but it is:
```
A * n * Result.
```
For example, for the input: 
```
**n** = 2
**A** = [1, 2, 3, 4, 5, 6]
```
You would need to use `[1, 2, 3, 4, 5, 6] * 2 * Result.`. 
[Try it online!](https://tio.run/##KyjKz8lP1y0uz/z/PzpWK14rOlaPy0fLTys6oCYo1ko3JzUvvSRDI0DHT1MnsaAgNS8FyA7R8dHUCQEqCrIOsPXRCbIFavr/n4sr2lBHwUhHwVhHwURHwVRHwUxHwVxHwSJWQUvBGIiDUotLc0r0uLgA "Prolog (SWI) ‚Äì Try It Online")
  
### Ungolfed version:
```
divide([], _, []).
divide(List, N, [Prefix | Result]) :-
    length(Prefix, N), append(Prefix, Remaining, List), divide(Remaining, N, Result) 
  ; Prefix = List, Result = [].
```
[Try it online!](https://tio.run/##TY7LCsIwEEX3@Yq7bGBa8C2KfyBFug1BCo11IKalrY@F/x6jjeLs5tzhzG27xjZ12t/Z@4pvXJlEacKRoLTMRER77gdCHuChMyd@4InC9Fc7aIlNKhDGGlcP52TMw60klG1rXPVDhbmU7NjVhLcvHET7X5BTFEsE6xbx3Q5jgzELq9KZ9@JbT00IU8KMMCcsCEvCirDWHxR9mRAv).
[Answer]
# PHP, 15 bytes
```
$f=array_chunk;
```
requires PHP 7. Call with `$f(ARRAY, N)`.
[Answer]
# [Perl 6](https://github.com/nxadm/rakudo-pkg), 13 bytes
```
{*.batch($_)}
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYPu/WksvKbEkOUNDJV6z9n9xYqVCGoipYainZ6apkJZfpGCkp2di/R8A "Perl 6 ‚Äì Try It Online")
Curried function wrapping the `batch` built-in.
[Answer]
# [Clean](https://github.com/Ourous/curated-clean-linux), 54 bytes
```
import StdEnv
$n l=[l%(i,i+n-1)\\i<-[0,n..length l-1]]
```
[Try it online!](https://tio.run/##Dcu9CsIwEADg3ae4oYLipRitTnbTQXDrmGYI6Y8Hl6vYKPjynn77F7kPomnqXtxDCiRK6TE9MzS5u8h7UQhw7Xi5IqSNGLtuWzoZt0UpS@5lzHdgY73XJof/qqGACpzFHe6xwgMevX7jwGGc1Vxvev5ISBTnHw "Clean ‚Äì Try It Online")
[Answer]
# [Python 2](https://docs.python.org/2/), 39 bytes
```
i,j=input()
while j:print j[:i];j=j[i:]
```
[Try it online!](https://tio.run/##K6gsycjPM/qfnJ@SqmCroK6u/j9TJ8s2M6@gtERDk6s8IzMnVSHLqqAoM69EISvaKjPWOss2KzrTKvY/RExJCw6UuIDauVIrUpM1wMZpKRhr/jfWiTbUMdIxjuUygbNgYjomOqY6ZjrmOhY6ljqGBrEA "Python 2 ‚Äì Try It Online")
Assumes that 1 chunk per line is acceptable output.
[Answer]
# Brainfuck, 71 bytes
```
,[>+>+<<-]>>>,[<[>.,<-]>>>++++[<++++++++>-]<.[-]<<<[<+>>+<-]<[->+<]>>>]
```
Dunno if this counts or not... input format:
```
<character whose ascii is n>AAAAAAAAAAAAA
For example, in the input:
 1234567890123492034
n is 32 since the ASCII value of space is 32
```
Takes the input and puts in a space every time `n` characters pass
Explanation (no commas because that would break the program):
```
, take n
[>+>+<<-] copy into next two cells (destroys original)
>>>, take first of A into next cell
[ while that input exists
<[>.,<-] if n is nonzero output take next of A subtract one from n
>>>++++[<++++++++>-]<.[-]< n is zero so put a space
<<[<+>>+<-] copy the old n into surrounding cells
<[->+<] move from first cell to second
>>>] take input, do again
```
[Answer]
# Python 3, 46 chars
```
lambda A,n:[A[:n],*(f(A[n:],n)if A[n:]else[])]
```
-1 thanks to @Collin Phillips.
[Try it online!](https://tio.run/##Hcs7DsIwEEXRrUzpQa/AhK8lCq/DTGGEDSOFSWTSsHoT0V3p6M7f5TXZ0Ov11sf8vj8yRVhIMQUTbFx1MVkQGGulf5bxU5Kw9Do1UlKjlu1ZnIffcpib2rJeyWOHAXsccMQJZ1xWFihz/wE)
[Answer]
# [CJam](https://sourceforge.net/p/cjam), 3 bytes
```
{/}
```
This is an anonymous block that takes an array of numbers and a number from the stack, and replaces them by an array of arrays.
[Try it online!](https://tio.run/##S85KzP0fbahgpGCsYKJgqmAWy2Xyv1q/9n9dwX8A "CJam ‚Äì Try It Online")
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 2 bytes
```
ƒ°‚Çé
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/r//8jCR019//9HRxvqGOkY65jomOqYxeqYxP6PAgA "Brachylog ‚Äì Try It Online")
[Answer]
# [Elixir](https://elixir-lang.org/), 16 bytes
```
Enum.chunk_every
```
[Try it online!](https://tio.run/##S83JrMgs@p9mq6bx3zWvNFcvOaM0Lzs@tSy1qPK/vpEml6e/XmZecUFqcolCmp5GtKGOgpGOgrGOgomOgqmOglkskE@MImNiFJlo/gcA "Elixir ‚Äì Try It Online")
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 1 byte
```
‚™™
```
[Try it online!](https://tio.run/##S85ILErOT8z5///RqlX//0crGRoZm5iamVtYKukomMQCAA "Charcoal ‚Äì Try It Online") Charcoal's default I/O makes it difficult to demonstrate using anything except strings. If you want a full program that takes numeric lists and outputs formatted lists then this can be done as follows:
```
Ôº•‚™™Ôº°ÔºÆ‚™´Œπ,
```
[Try it online!](https://tio.run/##S85ILErOT8z5/z@gKDOvRMM3sUAjuCAns0TDM6@gtERDU0cBzPArzU1KLdLQBPK98jPzNDJ1FJR0lDQ1Na3//4@ONtRRMNJRMNZRMNFRMNVRMNNRMNdRsNBRsIwFCsX@1y3LAQA "Charcoal ‚Äì Try It Online") Link is to verbose version of code. Explanation:
```
  Ôº°      Input array
 ‚™™       Split into chunks of
   ÔºÆ     Input number
Ôº•       Map over chunks
     Œπ  Current chunk
    ‚™´   Joined with
      , Literal `,`
        Implicitly print each chunk on its own line
```
[Answer]
# [C# (Visual C# Interactive Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), ~~78~~ ~~77~~ 43 bytes
```
a=>b=>{int i=0;return a.GroupBy(_=>i++/b);}
```
[Try it online!](https://tio.run/##Xc5NS8QwEAbge3/FsKeEjrW7fhxME1BREfYoeFgWSUNqg7uJpK2yhPz2mg0riHNI4J0nM1HDmRrM/DhZ1Tw/2GmvvWx3ujF2FJgO/Bv@B0JAB3wmElvKRUgRGF4zr8fJW5DVk3fT592BvHFhyvK8pSzOrCi@pAcz6v0AHKz@3mzDEld4gZd4hdeR5b7qJ/txBB3JFFe0enG33ssDoWlG5zyQvDCZmqWrOb2p1tq@j32KypIWoYBUSWupeiC/q8HYE9@YLc3mWPfODm6nq1ef0NpYTRZZ3YQ6QljGBYLBPCD9Ic4/ "C# (Visual C# Interactive Compiler) ‚Äì Try It Online")
I think we should be able to just write `int i;` because 0 is the default of int. I let it to avoid the error: `error CS0165: Use of unassigned local variable 'i'`.
[Answer]
# [F# (.NET Core)](https://www.microsoft.com/net/core/platform), 15 bytes
```
Seq.chunkBySize
```
[Try it online!](https://tio.run/##SyvWTc4vSv0fbainZx5bY/c/OLVQLzmjNC/bqTI4sypVweh/jV1BUWZeSVqegpKqo9J/AA "F# (.NET Core) ‚Äì Try It Online")
Well F# has a [builtin](https://msdn.microsoft.com/en-us/visualfsharpdocs/conceptual/list.chunkbysize['t]-function-[fsharp])...
[Answer]
# [J](http://jsoftware.com/), 4 bytes
```
<\~-
```
[Try it online!](https://tio.run/##y/qvpKeepmBrpaCuoKNgoGAFxLp6Cs5BPm7/bWLqdP9rcqUmZ@QrGCoYKRgrmCiYKpgppCkYYxM0wSZoaGDwHwA "J ‚Äì Try It Online")
Takes the array as left arg and chunk size as right arg.
Uses a dyadic hook and the [infix adverb](https://code.jsoftware.com/wiki/Vocabulary/bslash#dyadic) with a negative argument, which does what we want by definition.
Note: The return type *must* be boxed because J only allows tables of equal sized items.
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 2 bytes
```
√≤V
```
[Try it online!](https://tio.run/##y0osKPn///CmsP//ow11jHSMdUx0THXMYrmMFBQUuHQDAQ "Japt ‚Äì Try It Online")
[Answer]
# [PHP](https://php.net/), 45 bytes
```
function f($a,$b){return array_chunk($a,$b);}
```
[Try it online!](https://tio.run/##K8go@G9jXwAk00rzkksy8/MU0jRUEnVUkjSri1JLSovyFBKLihIr45MzSvOyoTLWtf8LijLzSuKLNNI0og11jHSMdUx0TGN1FIw0Na3/AwA "PHP ‚Äì Try It Online")
[Answer]
# Java 10, ~~106~~ 80 bytes
```
L->n->{for(int l=L.size(),i=0;i<l;)System.out.print(L.subList(i,(i+=n)<l?i:l));}
```
Prints the chunks without delimiter.
[Try it online.](https://tio.run/##dU9LTsMwEN33FKOubMW1KJ8uSByEkJCQyqpLxMJNnWqC40SxUxSqbDkAR@QiwYnSggosbNnz3rxPJndylm1eukRLa@FRotlPAKyTDhPIPMprh5qntUkcFobfj4/oG1uiddGDcWqrqpj9tXRXGFvnqjqyYkhBdMtZbGbxPi0qgsaBFktu8U0RylCchRjpkK4a61TOi9rxsvIk4in1unckyAgGwtBI3@C1pjRsu3Dis5f1WvvsY4VdgRvIfS2ycl5g@/QMkvYVAf5pANr/QIBRrz8ot1Ulm8H3ZGa5tMN8zs7ZBbtkV2zhwwwOh2Yo5iFgJBb@DoLRHuBXOQym8Pn@AdNx3ytwWZa6IX0mymWSqNLTjvCpgjZkxNpJf9ruCw)
### 106 bytes:
```
L->n->{var r=new java.util.Stack();for(int l=L.size(),i=0;i<l;)r.add(L.subList(i,(i+=n)<l?i:l));return r;}
```
Actually returns a list of lists.
[Try it online.](https://tio.run/##fVC7TgMxEOzzFSsqW@dYhEcKfA6iQUIKVUpE4dwj2sTxney9oBCl5QP4RH7kcI5DBKTgwlrP7Kxndmk2ZrjMV21mTQjwaNDtBgCBDGEGy8jKhtDKsnEZYeXkfV@kP9wUA6UPjopF4SfiX1HfddzUqU8MiwdK0O10OHHDyW5jPHjtipcj@YxMtmJclZVn6AisnsqArwXjAvW5wtQq7qXJcxbxZn4Yz1AwTLTjqb3FG8u58gU13oFX@1YNYvy6mdsYv9/CpsIc1nEzbEYe3eLpGQw/bAnghG@w8QUaflu9895sOwN/sCBN6PCRuBCX4kpci3F01f3wnQv1SAGmehzvJOEdBzDbBirWsmpI1tEaWReTncHH2zucJaU0dW237GCG9zV@zd0P9u0n)
**Explanation:**
```
L->n->{                       // Method with List and integer parameters and List return-type
  var r=new java.util.Stack();//  Create an empty List
  for(int l=L.size(),         //  Determine the size of the input-List
      i=0;i<l;)               //  Loop `i` in the range [0, size):
    r.add(                    //   Add to the result-List:
      L.subList(i,            //    A sublist of the input-list in the range from `i`
        Math.min(i+=n,l)));   //    to the minimum of: `i` + input-integer or the size
                              //    (and increase `i` by the input-integer at the same)
  return r;}                  //  Return the List of Lists of integers as result
```
[Answer]
# [K (oK)](https://github.com/JohnEarnest/ok), 10 bytes
```
{(0N,x)#y}
```
[Try it online!](https://tio.run/##y9bNz/7/P82qWsPAT6dCU7my9n@aQrSCibWhgpGCsYKJgqmCmULsfwA "K (oK) ‚Äì Try It Online")
[Answer]
# [Ruby](https://www.ruby-lang.org/), 25 bytes
```
->n,a{[*a.each_slice(n)]}
```
[Try it online!](https://tio.run/##KypNqvyfZvtf1y5PJ7E6WitRLzUxOSO@OCczOVUjTzO29n@BQlq0kU60oY6RjrGOiY6pjllsLBdI0BiboAma4H8A "Ruby ‚Äì Try It Online")
If we can return enumerators instead of arrays, then it becomes simply:
# [Ruby](https://www.ruby-lang.org/), 21 bytes
```
->n,a{a.each_slice n}
```
[Try it online!](https://tio.run/##KypNqvyfZvtf1y5PJ7E6US81MTkjvjgnMzlVIa/2f4FCWrSRTrShjpGOsY6JjqmOWWysXkl@fCIXSMYYp4wJNpn/AA "Ruby ‚Äì Try It Online")
[Answer]
# [PicoLisp](http://picolisp.com/), ~~75~~ 74 bytes
```
(de f(n l)(if(>= n(length l))(list l)(cons(head n l)(f n(tail(- 0 n)l)))))
```
[Try it online!](https://tio.run/##fco7DsJADIThnlNMOVsgAQl0cJc8dokly1mRbTj9xlBFihQXU/j7swyzypJr5RiRaNBASXw9YdRo7zL5J9Cb8qNhtoVT7Eb8y@RV6UR5xgUWvPSrzB@xogb3G3j1adDijofraavNobZ77b8x1BU "PicoLisp ‚Äì Try It Online")
[Answer]
# [Coconut](http://coconut-lang.org/), 8 bytes
```
groupsof
```
[Try it online!](https://tio.run/##S85Pzs8rLfmfpmCrEPM/vSi/tKA4P@1/tIaRjkK0oY6RjrGOiY6pjlmspo6ChjEWMRN0sViFGi07harMAjCdm1igolFQlJlXomCjpaenkKapUGOnALSzuDQ39T8A "Coconut ‚Äì Try It Online")
[Answer]
# [V](https://github.com/DJMcMayhem/V), 6 bytes
```
√≤√Äf,r
```
[Try it online!](https://tio.run/##K/v///Cmww1pOkVc//8b6hjpGOuY6JjqmP03AQA "V ‚Äì Try It Online")
Hexdump:
```
00000000: f2c0 662c 720a                           ..f,r.
```
Explanation:
```
√≤           " Until an error happens:
  f         "   (f)ind the...
 √Ä          "     n'th...
   ,        "     ","
            "   (If there are less than n commas after the cursor, throw an error)
    r       "   Replace the char under the cursor with...
     <cr>   "     A newline
```
[Answer]
# Clojure, 14 bytes
```
#(partition %)
```
builtins I guess
[Answer]
# [Haskell](https://www.haskell.org/), 26 bytes
```
import Data.Lists
chunksOf
```
Here's a more interesting version, with just a few more bytes (thanks to nimi for five bytes in each solution):
# [Haskell](https://www.haskell.org/), 31 bytes
```
n![]=[]
n!x=take n x:n!drop n x
```
[Try it online!](https://tio.run/##y0gszk7Nyfn/P08xOtY2OpYrT7HCtiQxO1UhT6HCKk8xpSi/AMT8n5uYmWdbUJSZV6JirKCooOQB1JWvUJKRWpSq9B8A "Haskell ‚Äì Try It Online")
[Answer]
# [PowerShell](https://github.com/TryItOnline/TioSetup/wiki/Powershell), ~~67~~ 65 bytes
*-2 bytes thanks AdmBorkBork*
```
param($n,$a)$a|%{$b+=,$_
if($b.Count-ge$n){,$b;rv b}}
if($b){,$b}
```
[Try it online!](https://tio.run/##fZDNCsIwEITveYqlrJLgKthWL1Io@CCSavyBWmtsVah59rpNRfSgOQxkZr4EpjzdjL3sTZ63uIUEmrbUVh8lFoRaoX4MGsxGCeFKHLYSs8nyVBfVeGewUA1htrBXyJzrQ@@41gmRSgF8SE4JIGUNKaKYZjRXxHd2FKUy7CTqJO5k1slcKfViw18s9SD1FH0g0W@E@o/oqx//63@9r@ABA2g8x@MAamtZzb0068pseDqeyIfWXOq8YmPIi2Lhmz4JXlEwNufgTQbCtU8 "PowerShell ‚Äì Try It Online")
[Answer]
# [R](https://www.r-project.org/), ~~49~~ 36 bytes
```
function(A,n)split(A,(seq(A)-1)%/%n)
```
[Try it online!](https://tio.run/##K/qfpmCj@z@tNC@5JDM/T8NRJ0@zuCAnswTI0ihOLdRw1NQ11FTVV83T/J@mYWhlpmOkyQVhGMMYJpr/AQ "R ‚Äì Try It Online")
Thanks to [Kirill L.](https://codegolf.stackexchange.com/users/78274/kirill-l) for the golf.
]