text:
Output the Source, One Bit at a Time
Write a non-empty program or function that when called outputs a single value, 1 or 0, and when called
multiple times, the output numbers produce the binary representation of your program's source code
(in the same code page from which your code is compiled/interpreted).
For instance, if your source code was abc (in ASCII), the outputs would be:
1st call:  0           // ASCII letter 'a'
2nd call:  1
3rd call:  1
4th call:  0
5th call:  0
6th call:  0
7th call:  0
8th call:  1

9th call:  0           // ASCII letter 'b'
10th call: 1
11th call: 1
12th call: 0
13th call: 0
14th call: 0
15th call: 1
16th call: 0

17th call: 0           // ASCII letter 'c'
18th call: 1
19th call: 1
20th call: 0
21st call: 0
22nd call: 0
23rd call: 1
24th call: 1

After the 24th call, the behaviour is undefined.

The binary representation of the source must contain at least one 0 bit and one 1 bit.
Instead of 1 and 0, you can output any two distinct, consistent values (such as true and false).
Self-modifying programs that output the binary representation of the original source are allowed, provided that they don't read the source code to find out what to print next.
This is code-golf, so the shortest answer in bytes wins.

Funky, 47 41 37 bytes
Returns a number representing a bit.
f=_=>1&("%b"%("f="+f)[i//8])>>7-i++%8

This uses the quine format of f=_=>"f="+f. It takes the character at position ⌊i/8⌋, then, gets the bit by taking the pairity of n >> 7-i%8 where n is the ascii value of the current character.
This is an iterative function that increments i with each call, once it's out of source code, it will write the code for n forever.
Try it online!

Is this a polyglot with JavaScript?

@StanStrum JS has no % operator for strings, and no // floor division operator.

Bash, 105 bytes
trap -- 'trap|xxd -b -c1|cut -d\  -f2|tr -d \\n|cut -c`x=\`cat f||echo 1\`;echo $((x+1))>f;echo $x`' EXIT

NOTE: Make sure that you don't have an important file called f in the directory you're testing this.

If you want to test this, you can use the following command:
for i in $(seq 848); do bash path/to/script.sh 2> /dev/null; done | tr -d \\n

Which should give the same output xxd -c1 -b path/to/script.sh|cut -d\  -f2|tr -d \\n.
Explanation
This is using the trap trick - calling trap inside the trap action simply prints that line. Next that output gets piped to xxd which converts it to binary (unfortunately xxd -bp doesn't work - thus the workaround with cut & tr):
xxd -c1 -b $0|cut -d\  -f2|tr -d \\n

From that we're only interested in one bit (say N) which we can select with cut -cN.
To find out what N we're using (remember that's the part that needs to be incremented after each call), simply try to set x to the content of the file f and if it doesn't exist set it to 1:
x=`cat f||echo 1`

Last thing to do, is to update the file f - writing x+1 to it:
echo $((x+1))>f

TI-Basic (TI-83 series), 592 357 309 bytes
"123456789ABCDEF02A3132333435363738394142434445463004AA003FB958833404593FB9588338045A3F3230363FDA582B383F303FCE5A405A6B3232333F5A70BB0FAA002BBB0CAA002B5A2B313FB932BA32F01058713459713511BB0FAA002BBB0CAA002B597031377132722B31→Str1
iPart(X/4→Y
iPart(X/8→Z
206
IS>(X,8
0
If Z and Z<223
Z+inString(Str1,sub(Str1,Z,1
iPart(2fPart(2^(X-4Y-5)inString(Str1,sub(Str1,Y+17-2Ans,1

This table is a possible reference for the calculator's binary representation of the source code, though ultimately I just used Virtual TI's debugger.
For comparison and/or historical interest: the first quines written in TI-Basic.
How it works
Str1 stores the source code (now in glorious hexadecimal, saving lots of space over the previous binary version), leaving out the bits where the contents of Str1 itself would be represented.
We're assuming that the program starts out on a calculator whose memory has just been cleared, so X is 0. Every time through the program, we increment X.
Usually, we just figure out the half-byte we're trying to extract a bit from, read it out of Str1, convert from hexadecimal to binary, and print it. If we're on the part of the source code that's storing Str1 (which is two-thirds of the total length of the program), then we first move to the corresponding part of the string storing 31, 32, and so on.

Java 8, 249 241 237 234 148 bytes
int i;v->{String s="int i;v->{String s=%c%s%1$c;return s.format(s,34,s).charAt(-i/8)>>(--i&7)&1;}";return s.format(s,34,s).charAt(-i/8)>>(--i&7)&1;}

Sorry in advance for the long explanations. :)

Whopping 89 bytes saved thanks to @Nevay.

Try it here.
Explanation:
int i;                     // Index-integer on class-level
v->{                       // Method with empty unused parameter and integer return-type
  String s="int i;v->{String s=%c%s%1$c;return s.format(s,34,s).charAt(-i/8)>>(--i&7)&1;}";
                           //  String containing the unformatted source code
  return s.format(s,34,s)  //    Quine to get the source code,
      .charAt(-i/8)        //     and get the character at index `-i/8`
     >>                    //    And bitwise right-shift it with:
       (--i&7)             //     `i-1` bitwise-AND 7
                           //     by first decreasing `i` by 1 with `--i`
      &1;                  //   Then bitwise-AND everything above with 1
}                          // End of method

Additional explanation:
quine-part:

String s contains the unformatted source code
%s is used to put this String into itself with s.format(...)
%c, %1$c and 34 are used to format the double-quotes (")
s.format(s,34,s) puts it all together

Try it here with some parts removed/modified to verify the quine outputs it's own source code.
binary-part:

-i/8 will automatically truncate on integer division, so when i is -7 to 0, it will become 0; if i is -15 to -8, it will become 1; etc.
So s.charAt(-i/8) takes the current character of the source-code, eight times after each other. Try it here with a modified version.
--i&7 will be 7,6,5,4,3,2,1,0,7,6,5,4,3,2,1,0,..., where the first 7 is when i=0 (which becomes -1 first due to the --i, and will keep decreasing).
s.charAt(-i/8)>>(--i&7) will produce sequences depending on the characters. Some examples ('A' (65) through 'E' (69) are):

A: 0,1,2,3,4,8,16,32,65,0,1,2,4,8,16,32,65,...;
B: 0,1,2,4,8,16,33,66,0,1,2,4,8,16,33,66,...;
C: 0,1,2,4,8,16,33,67,0,1,2,4,8,16,33,67,...;
D: 0,1,2,4,8,17,34,68,0,1,2,4,8,17,34,68,...;
E: 0,1,2,4,8,17,34,69,0,1,2,4,8,17,34,69,...;
etc.

...&1 then outputs a 0 if it's an even number, and 1 if it's an odd number, which in combination with the sequences above outputs the correct result.

Old 233 bytes answer:
int i;v->{String s="int i;v->{String s=%c%s%1$c;return Long.toString((s.format(s,34,s).charAt(i/8)&255)+256,2).substring(1).charAt(i++%%8);}";return Long.toString((s.format(s,34,s).charAt(i/8)&255)+256,2).substring(1).charAt(i++%8);}

Try it here.
Explanation:
int i;                           // Index-integer on class-level
v->{                             // Method with empty unused parameter and char return-type
  String s="int i;v->{String s=%c%s%1$c;return Long.toString((s.format(s,34,s).charAt(i/8)&255)+256,2).substring(1).charAt(i++%%8);}";
                                 //  String containing the unformatted source code
  return Long.toString(
          (s.format(s,32,s)      //  Quine-formatting
          .charAt(i/8)           //  Take the current character
           &255)+256,2).substring(1)
                                 //  Convert it to an 8-bit binary-String
         .charAt(i++%8);         //  And return the bit at index `i` modulo-8
                                 //  and increase index `i` by 1 afterwards with `i++`
}                                // End of method

Additional explanation:
quine-part:
Same explanation as above, with the addition of:

%% is the escaped form of the modulo-sign (%)

Try it here with some parts removed/modified to verify the quine outputs it's own source code.
binary-part:

i/8 will automatically truncate on integer division, so when i is 0-7, it will become 0; if i is 8-15, it will become 1; etc.
So s.charAt(i/8) takes the current character of the source-code, eight times after each other. Try it here with a modified version.
255 is 0xFF or 11111111 (the max value for an unsigned byte)
256 is 0x100 or 100000000.
The & upcasts the ASCII-character to an integer. At that point, it's anywhere between 0 and 255 (00000000 to 11111111).
Long.toString(...,2) converts it to the 9-bit binary String representation
+256 and .substring(1) will ensure there are leading zeroes, and will convert the 9-bit to an 8-bit.

Try it here with some parts removed/modified to verify the entire bytes.

149 bytes: int i;v->{String s="int i;v->{String s=%c%s%1$c;return 1&s.format(s,34,s).charAt(-i/8)>>(--i&7);}";return 1&s.format(s,34,s).charAt(-i/8)>>(--i&7);}

@Nevay Whopping 88 bytes saved. Thanks! And since it's actually quite a bit of a different approach than I originally had, I kept the old answer, and added the new. (If you want I'll remove it again and you can post it yourself, but you told me in the past you prefer to golf other people's - mainly mine XD - code instead of posting your own answer, right?)

Javascript ES6, 73 58 52 bytes
o=_=>`o=${o}`.charCodeAt((o.n=1+o.n|0)/8)>>(7-o.n%8)&1

Explanation
Breakdown of the code:

o=_=>: define a function.
`o=${o}`: construct a string; o is converted to a string, which in this case is the function's source code.
.charCodeAt(: get a character in the string as its ASCII character code.
(o.n=1+o.n|0)/8: select a character. This is also where the counter is incremented.
)>>(7-o.n%8): shift the resulting character code so that the desired bit is in the right position.
&1: set all other bits to 0.

You can shorten this with a lambda into o=_=>(o+'').charCodeAt(('n'in top?++n:n=0)/8|0)>>(7-n%8)&1

This counts as defining a function.

Try o=_=>('o='+o).charCodeAt(('n'in top?++n:n=0)/8|0)>>(7-n%8)&1

Instead of 'n'in top?++n:n=0 you can use ++n||(n=0) or ++n?n:n=0 or n=++n||0 or n=1+n||0 which all utilise the falsiness of NaN that is produced by incrementing undefined

o=_=>('o='+o).charCodeAt((o.n=1+o.n|0)>>3)>>(~o.n&7)&1

o=_=>('o='+o).charCodeAt((o.n=1+o.n|0)/8)>>(~o.n&7)&1

q/kdb+, 45 bytes
Solution:
a:-1;f:{((,/)0b vs'4h$"a:-1;f:",($).z.s)a+:1}

Example:
q)f[] / call function f with no parameters
0b
q)f[]
1b
q)f[]
1b
q)f[]
0b
q)f[]
0b
q)f[]
0b
q)f[]
0b
q)f[]
1b
q)f[]
q)"c"$0b sv 01100001b / join back to a byte and cast to a character
"a"

Explanation:
I think I understood the brief.
First setup a global variable a with starting value of -1. Function f builds the binary representation of the string representation of the function (everything including the {}) prepended with the a:-1;f: junk, and indexes into this binary list at index a (which gets incremented each call).
a:-1;f:{(raze 0b vs'4h$"a:-1;f:",string .z.s)a+:1} / ungolfed solution
a:-1;                                              / stick -1 in variable a
     f:{                                         } / define function f
                                             a+:1  / increment a by 1 (:: is required as a is a global variable), indexes into the left
        (                                   )      / do all this together
                                 string .z.s       / z.s is the function, string converts it to a string
                       "a:-1;f:",                  / prepend "a:-1;f:" to the start
                    4h$                            / cast to bytes
              0b vs'                               / convert each byte to binary
         raze                                      / flatten binary into long list

Python 2, 164 bytes
lambda s='lambda s=%r,i=[]:i.append(1)or"{:08b}".format(ord((s%%s)[~-len(i)/8]))[~-len(i)%%8]',i=[]:i.append(1)or"{:08b}".format(ord((s%s)[~-len(i)/8]))[~-len(i)%8]

Try it online!
Explanation
Let's start with a standard Python 2 quine.
s = '...'; print s % s

Okay, well, this outputs it just like that. We need binary!
s = '...'; print "\n".join("\n".join("{:08b}".format(ord(i))) for i in s % s)

Right, that just converts everything to binary. But the title says "one bit at a time". We need something to persist through multiple runs. I know, let's make it a function!
lambda s = '...': "\n".join("\n".join("{:08b}".format(ord(i))) for i in s % s)

Wait, that doesn't help... Hmm, how can we keep track of the index of the bit needed to be output? Ooh, ooh, let's have an integer to keep track.
lambda s = '...', i = 0: "{:08b}".format(ord((s % s)[i / 8]))[i % 8]

Um... that always outputs the first bit. Oh, we need to increment the tracker! Oh crap, Python doesn't allow integers as default arguments to be modified. And assignments aren't expressions in Python, so you can't do that in a lambda. Welp, this is impossible in Python, case closed.
...Well, not quite. Python does allow lists as default arguments to be modified. (And it bites Python programmers all the time.) Let's use its length!
lambda s = '...', i = []: "{:08b}".format(ord((s % s)[len(i) / 8]))[len(i) % 8]

That still doesn't modify the tracker though... We can append something to it to increase its length... But how? Ah, well, we've got list.append. lst.append(1) is equivalent to lst += [1]. Great!
lambda s = '...', i = []: i.append(1) and "{:08b}".format(ord((s % s)[len(i) / 8]))[len(i) % 8]

Whoops, this skips the first bit because the length of the tracker is 1 before the bit is outputted. We need to decrement the length where it's used.
lambda s = '...', i = []: i.append(1) and "{:08b}".format(ord((s % s)[(len(i) - 1) / 8]))[(len(i) - 1) % 8]

There it is, folks! Golf it and you've got my solution!

Perl 5, 59 bytes
sub{$_=q{unpack(B.++$-,"sub{\$_=q{$_};eval}")=~/.$/g};eval}

Try it online!


text:
Smallest Zeroless Base
Given a positive integer n, output the smallest base b >= 2 where the representation of n in base b with no leading zeroes does not contain a 0. You may assume that b <= 256 for all inputs.
Test Cases
1 -> 2 (1)
2 -> 3 (2)
3 -> 2 (11)
4 -> 3 (11)
5 -> 3 (12)
6 -> 4 (12)
7 -> 2 (111)
10 -> 4 (22)
17 -> 3 (122)
20 -> 6 (32)
50 -> 3 (1212)
100 -> 6 (244)
777 -> 6 (3333)
999 -> 4 (33213)
1000 -> 6 (4344)
1179360 -> 23 ([12, 9, 21, 4, 4])
232792560 -> 23 ([15, 12, 2, 20, 3, 13, 1])
2329089562800 -> 31 ([20, 3, 18, 2, 24, 9, 20, 22, 2])
69720375229712477164533808935312303556800 -> 101 ([37, 17, 10, 60, 39, 32, 21, 87, 80, 71, 82, 14, 68, 99, 95, 4, 53, 44, 10, 72, 5])
8337245403447921335829504375888192675135162254454825924977726845769444687965016467695833282339504042669808000 -> 256 ([128, 153, 236, 224, 97, 21, 177, 119, 159, 45, 133, 161, 113, 172, 138, 130, 229, 183, 58, 35, 99, 184, 186, 197, 207, 20, 183, 191, 181, 250, 130, 153, 230, 61, 136, 142, 35, 54, 199, 213, 170, 214, 139, 202, 140, 3])

What are the values for ten, eleven, etc. in higher bases you are using? Do they contain zeroes?

@Stephen The OP talking about the array-based representations of them, not the actual string representation

@Stephen The values chosen for digits above 9 do not matter, because they are not 0.

Related.

This is OEIS A106370.

What if builtins can´t do base 1000?

@Titus That's a good point. I'll limit the base to something reasonable.

you should probably explicitly say you can't use fractional part numbers (10 = 9.999..., 17000 = 17999.999...)

Could you add a couple of test cases with larger (>36) outputs?

@DestructibleLemon Do you mean 17000=16999,999...? Because it's certainly not 17999,999...

@Shaggy I tested my MATL entry up to 1e6, and didn't get beyond base 20 at n=658370

The question title is misleading, and perhaps impossible. Don't all bases use zeros? Perhaps it should be "Smallest Base of Zeroless Representation".

@CJDennis You're reading too much into it.

@Shaggy I'm still searching for cases where b > 20. It's taking a while!

@Mego: Try 232792560.  It's the lcm of 2,3,...,20, so in every base <= 20 it has a 0 as the least significant digit.

While the larger test cases are interesting, are we required to handle them? If our language doesn't support extended integers, for example, or at least, not by default?

@ConorO'Brien By the meta consensus, no.

@Mego Which meta consensus, for future reference?

@ConorO'Brien There's not a hard consensus, but the answers to this question all share the same idea that cases where the input and/or output exceed the language's representable range need not be considered.

Pyth, 6 bytes
f*FjQT

Verify all the test cases.
How it works

f*FjQT  ~ Full program.

f       ~ First positive integer where the condition is truthy.
   jQT  ~ The input converted to base of the current element.
 *F     ~ Product. If the list contains 0, then it's 0, else it is strictly positive.
          0 -> Falsy; > 0 -> Truthy.
        ~ Output the result implicitly.

Although Pyth's f operates on 1, 2, 3, 4, ... (starting at 1), Pyth treats numbers in base 1 (unary) as a bunch of zeros, so base 1 is ignored.

Nice abuse of the fact that Pyth's base-1 representation is all-zeroes.

@EriktheOutgolfer Thanks! I will add an explanation regarding that.

Pyth isn't the only language whose unary representation uses zeroes as digits hint :P

You wrote 0 -> Falsy; > 0 -> Truthy. Is that intentional that 0 is both Truthy and Falsy in that situation?

@BrianJ There is a > sign in front of the second 0, which means that everything higher than 0 is truthy.

@Mr.Xcoder D'oh, completely missed it the first read. Thanks!

.A (all) would be a bit more natural than *F, but this works just as well.

@isaacg Thanks, thought of that too but it wouldn't change much nonetheless. I was wondering though, why can't I remove the trailing T (the error messages when T is removed seem quite misleading)?

j allows a single input the way f does. On one input, j is the join function, which is not what we want here.

@isaacg Duh right, I forgot about j's overloads >.<

C,  52  50 bytes
i,k;f(n){for(i=2,k=n;k;)k=k%i++?k/--i:n;return i;}

Try it online!
C (gcc),  47  45 bytes
i,k;f(n){for(i=2,k=n;k;)k=k%i++?k/--i:n;n=i;}

Try it online!

Two bytes saved thanks to @Nevay's suggestion on @Kevin Cruijssen's answer!

The latter version works only by random luck, even if you insist on a specific compiler. And, of course, neither version is really C.

@AnT it is C.. it will give a lot of warnings but it will compile. as long as you find a compiler that works for your code, you're fine

46: k=k%i --> k%=i, IIRC

@Blacksilver k%i is a ternary-check here. A more readable variant would be k=(k%i?k:n*++i); or even more clearly: if(k%i){k=k;}else{k=n*++i;}.

Also, you can golf both by 2 bytes: i,k;f(n){for(i=2,k=n;k;)k=k%i++?k/--i:n;return i;} and i,k;f(n){for(i=2,k=n;k;)k=k%i++?k/--i:n;n=i;}. All credit goes to @Nevay who posted this suggestion on my ported Java 8 answer.

@Felipe Nardi Batista: I'm aware of the fact that CodeGolf rules say "as long as it compiles" and so on. However, the fact that it "compiles" does not in any way prove that it is C. This is not C. Typeless declarations like i, k; and f(n) existed in ancient versions of C (K&R), but only in the era when return required round brackets around its argument. If you want to use K&R with i,k;, you also have to use return(i);. The above might be gnuc, but not C.

@AnT Yeah, it's not real, modern (or any other particular era) C, but as long as it compiles with a C compiler, it can be called C here, because on PPCG a language is defined by its implementation.

@Steadybox: Yes, but how do PPCG rules establish connection between "language" to "its implementation"? Who said that defalt-configured gcc compiler is an implementation of C? In fact, everybody knows that it isn't.

@AnT While a default-configured gcc-compiler doesn't implement the C standard precisely, I think it still is reasonable to call code written for it C. It still is a version of C, even if it's not a standard version.

@AnT: I've specifically called for tcc a few times.

Nice.  Note code fails for OP's last 3 test cases with 32-bit int.  Certainly has trouble with many values > INT_MAX

@chux Yep, it can't handle inputs larger than INT_MAX as is, but that's okay.

Haskell, 56 52 48 bytes
b#n=n<1||mod n b>0&&b#div n b
f n=until(#n)(+1)2

Try it online!
Pretty basic but can't think of any good ways to shorten it
EDIT: Thanks to Laikoni for saving me 4 bytes! Don't know why I never thought of !!0. I probably should've tried removing those parentheses but I have vague memories of some weird error when you try to use || and && together. Maybe I'm confusing it with the equality operators.
EDIT 2: Thanks @Lynn for shaving another 4 bytes! Don't know how I never knew about until before now.

You beat me by a minute with nearly exactly the same solution. :) !!0 is shorter than head and I think you can drop the parenthesis in #.

The criminally underrated until :: (a → Bool) → (a → a) → a → a saves four bytes: f n=until(#n)(+1)2

Wolfram Language (Mathematica), 33 bytes
2//.i_/;DigitCount[#,i,0]>0:>i+1&

Try it online!

Husk, 7 bytes
→V▼MBtN

Try it online!
Explanation
→V▼MBtN
     tN    list of natural numbers starting from 2
   MB      convert the (implicit) input to each of those bases
 V▼        find the (1-based) index of the first result where the minimum digit is truthy
→          add 1 to this index

Jelly, 7 bytes
2b@Ạ¥1#

Try it online!

Python 2, 57 bytes
n=x=input()
b=2
while x:z=x%b<1;b+=z;x=[x/b,n][z]
print b

Try it online!
This is one byte shorter than a recursive function:
f=lambda n,b=1,x=1:b*(x<1)or f(n,b+(x%b<1),[x/b,n][x%b<1])

BTW this is pretty similar to my solution.

APL (Dyalog), 20 19 bytes
1+⍣{~0∊⍺⊥⍣¯1⊢n}≢n←⎕

Try it online!
As usual, thanks to @Adám for helping out in chat and getting the code to work in TIO. Also, saving 1 byte.
This is tradfn (traditional function) body. To use it, you need to assign it a name (which is in TIO's header field), enclose it in ∇s (one before the name and one in TIO's footer field), and then call it using its name. Since it uses a quad (⎕) to take the user's input, it's called as f \n input instead of the usual f input
How?
1+⍣{~0∊⍺⊥⍣¯1⊢n}≢n←⎕  ⍝ Main function.
                  n←⎕ ⍝ Assigns the input to the variable n
1+⍣{           }≢     ⍝ Starting with 1, add 1 until the expression in braces is truthy
    ~0∊               ⍝ returns falsy if 0 "is in"
        ⊥             ⍝ convert
            ⊢n        ⍝ the input
         ⍣¯1          ⍝ to base
       ⍺              ⍝ left argument (which starts at 1 and increments by 1)

The function then returns the resulting base.

Golfing tip: since n←⎕ will be a simple number and you need 1 as initial argument to the rest of the code, you can just count the number of elements in n (which is 1), by replacing 1⊣ with ≢. Try it online!

05AB1E, 6 bytes
-4 bytes thanks to Adnan
1µNвPĀ

Try it online!

10 bytes: [¹NÌDŠвPĀ#

1µNвPĀ works for 6 bytes

@Adnan I knew it was way too long

LB0.å0k is another method entirely >_>.

Husk, 9 bytes
←foΠ`B⁰tN

Try it online!
Explanation
            -- input N
        tN  -- tail of [1..] == [2..]
←f(    )    -- filter with the following:
    `B⁰     --   convert N to that base
   Π        --   product (0 if it contains 0)
←           -- only keep first element

Java 8, 61 56 54 bytes
n->{int b=2,t=n;for(;t>0;)t=t%b++<1?n:t/--b;return b;}

Try it here.
Explanation:
n->{            // Method with integer as both parameter and return-type
  int b=2,      //  Base-integer, starting at 2
      t=n;      //  Temp-integer, copy of the input
  for(;t>0;)    //  Loop as long as `t` is not 0
    t=t%b++<1?  //   If `t` is divisible by the base `b`
                //   (and increase the base `b` by 1 afterwards with `b++`)
       n        //    Set `t` to the input `n`
      :         //   Else:
       t/--b;   //    Divide `t` by the `b-1`
                //    (by decreasing the base `b` by 1 first with `--b`)
                //  End of loop (implicit / single-line body)
  return b;     //  Return the resulting base
}               // End of method

I have the feeling this can be golfed by using an arithmetic approach. It indeed can, with a port of @Steadybox' C answer, and then golfed by 2 bytes thanks to @Nevay.
Old (61 bytes) answer:
n->{int b=1;for(;n.toString(n,++b).contains("0"););return b;}

Try it here.
Explanation:
n->{         // Method with Integer as both parameter and return-type
  int b=1;   //  Base-integer, starting at 1
  for(;n.toString(n,++b).contains("0"););
             //  Loop as long as the input in base-`b` does contain a 0,
             //  after we've first increased `b` by 1 before every iteration with `++b`
  return b;  //  Return the resulting base
}            // End of method

54 bytes: n->{int b=2,t=n;for(;t>0;)t=t%b++<1?n:t/--b;return b;}

Python 2, 57 bytes
n=m=input()
b=2
while m:c=m%b<1;b+=c;m=(m/b,n)[c]
print b

Try it online!
-1 thanks to Felipe Nardi Batista.
-2 thanks to Lynn (and now this is a dupe of her solution :D)

59 bytes by changing a,b=a+c,d to a+=c;b=d

I think you can replace while m>1 by while m (and then we’re tied!)

@Lynn That's why I commented on your solution, it would be exactly the same then.

That’s okay!

@Lynn I already knew :p otherwise I'd have asked you to delete yours.

Japt, 8 bytes
@ìX e}a2

Try it online!
Explanation
@    }a2

Return the first number (X) to pass the function, starting at 2
ìX

Convert the input number to an array of base-X digits.
e

Check if all digits are truthy.

Won't this fail if the array contains any multiple of 10?

@Shaggy My understanding was that, according to OPs comment, that the digits for bases above 9 don't count as zero.

Ah, I see that now. There's a problem with the phrasing of the challenge, so (or I'm just too tired!).

JavaScript (ES6), 43 41 37 bytes
n=>(g=x=>x?g(x%b++?x/--b|0:n):b)(b=1)

Test cases

let f =

n=>(g=x=>x?g(x%b++?x/--b|0:n):b)(b=1)

console.log(f(1   )) // 2 (1)
console.log(f(2   )) // 3 (2)
console.log(f(3   )) // 2 (11)
console.log(f(4   )) // 3 (11)
console.log(f(5   )) // 3 (12)
console.log(f(6   )) // 4 (12)
console.log(f(7   )) // 2 (111)
console.log(f(10  )) // 4 (22)
console.log(f(17  )) // 3 (122)
console.log(f(20  )) // 6 (32)
console.log(f(50  )) // 3 (1212)
console.log(f(100 )) // 6 (244)
console.log(f(777 )) // 6 (3333)
console.log(f(999 )) // 4 (33213)
console.log(f(1000)) // 6 (4344)

Brachylog, 11 bytes
;.≜ḃ₎¬∋0∧1¬

Try it online!
Explanation
;.≜ḃ₎           The Input represented in base Output…
     ¬∋0        …contains no 0
        ∧1¬     And Output ≠ 1

Proton, 40 bytes
x=>filter(y=>all(digits(y,x)),2..x+3)[0]

Try it online!

This is invalid. 2..x checks for bases in the interval [2, x), hence it fails for test cases 1 and 2.

R, 79 71 66 63 65 bytes
function(n){while(!{T=T+1;all(n%/%T^(0:floor(log(n,T)))%%T)})T
T}

Try it online!
This answer is based on Giuseppe's re-arrangement in one single loop.
Saved 8 bytes thanks to JDL, and 6 bytes thanks to Giuseppe.

You can sub b for T, which starts out defined as TRUE == 1, removing the need for b=1. Similarly you can sub F for k (F is FALSE)

I see what you did there. That's a useful one to know!

66 bytes using m%/%T (integer division) instead of (m-m%%T)/T

65 bytes. it was a bit messy but I suspected getting rid of the nested loops would save something; I just thought it would be more than 1 byte :(

MATL, 13 12 bytes
`G@Q_YAA~}@Q

Try it online!
-1 byte thanks to Luis Mendo. This program does not handle testcases bigger than 2^53 (flintmax, the maximum consecutive integer representable by a floating point type), as the default datatype is double in MATL. However, it should be able to find any arbitrary zeroless base below that number.
`            % Do while
 G           %  Push input
  @ _        %  Outputs the iteration number, negate.
     YA      %  Convert input to base given by the iteration number, the negative number is to instruct MATL we want an arbitrary high base with a integer vector rather than the default character vector we know from hexadecimal
       A~    %  If they're not all ones, repeat
         }   % But if they are equal, we finally
          @  %  Push the last base
   Q       Q %  As base 1 makes no sense, to prevent MATL from errors we always increase the iteration number by one.

@LuisMendo I should really start reading the docs better. Thanks.

This doesn't seem to work for the larger test cases, but I don't know enough about MATL/Matlab to know if that's caused by integer limits or not.

@Mego I tested my 13 byte version which should be equivalent to the current version up to 1e6, on MATLAB R2017a. What test setup resulted in problems for you?

The last 2 test cases cause errors.

@Mego Ah I didn't see those testcases before. This is due to the implementation of MATLs YA using doubles internally, so it can only handle inputs up to the maximum consecutive integer representable by a double (see flintmax). Does this invalidate the answer? In principle the algorithm works for arbitrary base, I've explicitly worked around another command that would only do up to base 36.

@Mego Actually, I've spotted your comment on the OP. Thanks for spotting the limitation though, I may want to try and make a MATLAB version that uses arbitrary precision integers.

><>, 56 52 51 49 bytes
:2&v
1(?\:&:&:@%@,:1%-:
 v~<
l<*v?=2
&v?/:&+1
n>&

Try it online!
The interpreter bugs out on the last 2 testcases.
It only reads the first 16 digits of the input correct and then replaces the rest with other digits.

Stacked, 23 bytes
{!2[1+][n\tb all]until}

Try it online!
This increments ([1+]) J starting from two (2) while the baseJ  representation of the input has no zeroes (all and until).

Actually,  12  11 bytes
╗1⌠╜¡m'0<⌡╓

Try it online!
Uses this consensus. Thanks to Mego for byte-saving help in chat.

PHP, 59+1 bytes
using builtins, max base 36:
for($b=1;strpos(_.base_convert($argn,10,++$b),48););echo$b;

no builtins, 6360+1 bytes, any base:
for($n=$b=1;$n&&++$b;)for($n=$argn;$n%$b;$n=$n/$b|0);echo$b;

Run as pipe with -nR or try them online.

J, 26 bytes
]>:@]^:(0 e.]#.inv[)^:_ 2:

Would love to know if this can be improved.
The main verb is a the dyadic phrase:
>:@]^:(0 e.]#.inv[)^:_

which is given the input on the left and the constant 2 on the right.  That main verb phrase then uses J's Do..While construct, incrementing the right y argument as long as 0 is an element of e. the original argument in base y.
Try it online!

Lua, 77 76 bytes
b=2n=...N=n
while~~N>0 do
if N%b<1then
b=b+1N=n
else
N=N//b
end
end
print(b)

Try it online!

Milky Way, 38 bytes
^^'%{255£2+>:>R&{~^?{_>:<;m_+¡}}^^^}

usage: ./mw base.mwg -i 3

Explanation
code                                 explanation                    stack layout

^^                                   clear the preinitialized stack []
  '                                  push the input                 [input]
   %{                              } for loop
     255£                             push next value from 0..254   [input, base-2]
         2+                           add 2 to the get the base     [input, base]
           >                          rotate stack right            [base, input]
            :                         duplicate ToS                 [base, input, input]
             >                        rotate stack right            [input, base, input]
              R                       push 1                        [input, base, input, 1]
               &{~             }      while ToS (=remainder) is true ...
                  ^                    pop ToS                      [input, base, number]
                   ?{         }        if ToS (=quotient) ...
                     _>:<;              modify stack                [input, base, number, base]
                           m            divmod                      [input, base, quotient, remainder]
                           _+¡         else: output ToS (0) + SoS and exit
                                ^^^   pop everything but the input.

I'm sure this can be shortened using a while-loop instead of a for loop, but I couldn't get it to work.

Perl 5, 52 + 2 (-pa) = 54 bytes
$\=1;while($_&&=$F[0]){$\++;$_=int$_/$\while$_%$\}}{

Try it online!

Pip, 12 bytes
T NyYaTD Uoo

Try It Online!
Explanation
An iterative solution:
T NyYaTD Uoo
              a is command-line input; y is ""; o is 1 (implicit)
T             Loop until
  Ny          Min(y) is truthy:
         Uo     Increment o
     aTD        Convert a to list of digits in that base
    Y           Store that list in y
           o  After the loop, output o

Alternate solution using filter, also 12 bytes:
@:NaTD_FI2,m
              a is command-line input; m is 1000 (implicit)
         2,m  Range from 2 to 999 (could be 256, but using m is shorter)
       FI     Filter, keeping elements for which this function returns truthy:
   aTD_         Convert a to list of digits in base (function argument)
  N             Get the minimum
@:            Take the first element of the filtered list

Try It Online!

Ruby, 41 bytes
->n{(2..).find{!n.digits(_1).include? 0}}

Attempt This Online!

Stax, 7 bytes
Ç╔ü$■╖Ö

Run and debug it
Trivial brute force approach

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

sort: votes


text:
Deal an ASCII Deck
There's never really been a definitive ASCII-cards challenge AFAIK. So, using the following deck of ASCII cards:
.------..------..------..------..------..------..------..------..------..------..------..------..------.
|2.--. ||3.--. ||4.--. ||5.--. ||6.--. ||7.--. ||8.--. ||9.--. ||T.--. ||J.--. ||Q.--. ||K.--. ||A.--. |
| (\/) || (\/) || (\/) || (\/) || (\/) || (\/) || (\/) || (\/) || (\/) || (\/) || (\/) || (\/) || (\/) |
| :\/: || :\/: || :\/: || :\/: || :\/: || :\/: || :\/: || :\/: || :\/: || :\/: || :\/: || :\/: || :\/: |
| '--'2|| '--'3|| '--'4|| '--'5|| '--'6|| '--'7|| '--'8|| '--'9|| '--'T|| '--'J|| '--'Q|| '--'K|| '--'A|
'------''------''------''------''------''------''------''------''------''------''------''------''------'
.------..------..------..------..------..------..------..------..------..------..------..------..------.
|2.--. ||3.--. ||4.--. ||5.--. ||6.--. ||7.--. ||8.--. ||9.--. ||T.--. ||J.--. ||Q.--. ||K.--. ||A.--. |
| :/\: || :/\: || :/\: || :/\: || :/\: || :/\: || :/\: || :/\: || :/\: || :/\: || :/\: || :/\: || :/\: |
| :\/: || :\/: || :\/: || :\/: || :\/: || :\/: || :\/: || :\/: || :\/: || :\/: || :\/: || :\/: || :\/: |
| '--'2|| '--'3|| '--'4|| '--'5|| '--'6|| '--'7|| '--'8|| '--'9|| '--'T|| '--'J|| '--'Q|| '--'K|| '--'A|
'------''------''------''------''------''------''------''------''------''------''------''------'
.------..------..------..------..------..------..------..------..------..------..------..------..------.
|2.--. ||3.--. ||4.--. ||5.--. ||6.--. ||7.--. ||8.--. ||9.--. ||T.--. ||J.--. ||Q.--. ||K.--. ||A.--. |
| :/\: || :/\: || :/\: || :/\: || :/\: || :/\: || :/\: || :/\: || :/\: || :/\: || :/\: || :/\: || :/\: |
| (__) || (__) || (__) || (__) || (__) || (__) || (__) || (__) || (__) || (__) || (__) || (__) || (__) |
| '--'2|| '--'3|| '--'4|| '--'5|| '--'6|| '--'7|| '--'8|| '--'9|| '--'T|| '--'J|| '--'Q|| '--'K|| '--'A|
'------''------''------''------''------''------''------''------''------''------''------''------''------'
.------..------..------..------..------..------..------..------..------..------..------..------..------.
|2.--. ||3.--. ||4.--. ||5.--. ||6.--. ||7.--. ||8.--. ||9.--. ||T.--. ||J.--. ||Q.--. ||K.--. ||A.--. |
| :(): || :(): || :(): || :(): || :(): || :(): || :(): || :(): || :(): || :(): || :(): || :(): || :(): |
| ()() || ()() || ()() || ()() || ()() || ()() || ()() || ()() || ()() || ()() || ()() || ()() || ()() |
| '--'2|| '--'3|| '--'4|| '--'5|| '--'6|| '--'7|| '--'8|| '--'9|| '--'T|| '--'J|| '--'Q|| '--'K|| '--'A|
'------''------''------''------''------''------''------''------''------''------''------''------''------'

Take two integers, p and q as input; where p is the number of players and q is the number of cards each player gets.

Randomly shuffle the deck of cards (this is ambiguous, but means that all cards must be equally likely to appear anywhere once).
Deal 1 round of cards per player, outputting q rows of p cards each row.

Rules:

The results should be uniformly random, each card should be equally likely to appear anywhere.
It is guaranteed that 0 < p*q <= 52 and p < 10, you may have undefined behavior for scenarios where this is not met.
You should output q rows of cards with p cards per row.
Each column should be separated by  |  (a pipe char surrounded by spaces); if you choose a different char than this, explain why. Surrounding spaces here are NOT optional.
Each row must have 1 or more newlines inbetween them, more than one is acceptable, 0 is not (1 newline meaning the newline there by default).
Each row should be labeled with the player who owns it in the format "Player N" (0 or 1-indexed is fine).
No one card may appear more than once.
T is for Ten.

Examples:
Function(p=1,q=1):
Player 1 # Can also be 0.
.------.
|2.--. |
| (\/) |
| :\/: |
| '--'2|
'------'

Function(p=2,q=1):
Player 1 | Player 2 # Can also be "Player 0 | Player 1"
.------. | .------.
|2.--. | | |T.--. |
| (\/) | | | (\/) |
| :\/: | | | :\/: |
| '--'2| | | '--'T|
'------' | '------'

Function(p=2,q=2):
Player 1 | Player 2 # Can also be "Player 0 | Player 1"
.------. | .------.
|J.--. | | |3.--. |
| (\/) | | | :/\: |
| :\/: | | | :\/: |
| '--'J| | | '--'3|
'------' | '------'
.------. | .------.
|8.--. | | |6.--. |
| :(): | | | :/\: |
| ()() | | | (__) |
| '--'8| | | '--'6|
'------' | '------'

Artistic credit to a font on: http://patorjk.com/software/taag

Are you going to post many card-challenges from the cards you found at http://patorjk.com/software/taag?

@StraklSeth I mean, sure? The licence of that site doesn't even require credit for use. Though I probably should give it. I've used altered versions of their fonts for 3 challenges thus far.

Soooo...Can we "use" this site to output the result???

@Jenny_mathy I mean: loopholes, formatting, transformations, headers, column separators and other such things would probably prevent that... But if you want to make major edits after typing "123456789TJQKA" to make a challenge then sure you can use that site.

I mean: Can I make a program that outputs http://patorjk.com/software/taag/#p=display&f=Cards&t=J3%0A86%0A%0A%0A  this for your last test case?

Can't each player's cards be separated vertically? :(

Also, Each row must have 1 or more newlines inbetween them, more than one is acceptable, 0 is not. ...But your test cases don't have newlines between cards..?

There was almost one challenge on ASCII cards: Play time posted by me.

Charcoal, 142 133 125 bytes
ＮθＦＮ«Ｆ¬¬ι«→↑×⁶θ| »Player ＩιＦθ«↙↓.↓⁴←'←⁶↑'↑⁴.Ｐ⁶↓≔‽⁵²εＷ№υε≔‽⁵²ε⊞υε≔§”w↘τ[⁵ＰkxτG”εδδ.--.¶✂”{➙aＥTê；s∨Hμ⁼⎚↑Ｚ～ＳÀd～⌀Ｔê”﹪ε⁴φ⁴'--'δ↘

Try it online! Link is to verbose version of code. Edit: Saved 9 bytes by improving my random sampling code. Saved a further 8 bytes by improving my suit printing code. Explanation:
Ｎθ

Read the number of cards into q.
ＦＮ«

Loop over each player.
Ｆ¬¬ι«→↑×⁶θ| »

If this is not the first player, print the vertical line between the previous and this player.
Player Ｉι

Print the player number.
Ｆθ«

Loop over each card.
↙↓.↓⁴←'←⁶↑'↑⁴.Ｐ⁶↓

Print the card's edge.
≔‽⁵²εＷ№υε≔‽⁵²ε⊞υε

Pick a card index that hasn't already been picked, and add it to the list of picked card indices.
≔§”w↘τ[⁵ＰkxτG”εδδ

Choose and print the card's rank by cyclically indexing into a string of valid card ranks (2-9, T, J, Q, K, A).
.--.¶

Print the top of the suit.
✂”{➙aＥTê；s∨Hμ⁼⎚↑Ｚ～ＳÀd～⌀Ｔê”﹪ε⁴φ⁴

Print the middle of the suit by slicing into a string. The slice begins at the card index modulo 4 and takes every 4th character until the string runs out (or the f=1000th character is reached). Since 4 and 13 are coprime this ensures that all 52 cards are possible.
'--'δ↘

Print the bottom of the suit and a copy of the rank, and then move to a point that conveniently is not too far away from either the copy of the rank, the start of the next card, or the start of the dividing line for the next player.

When I saw this in the sandbox it was a k-c challenge to print the deck, which took me 102 bytes: Try it online! Link is to verbose version of code.

Python 2, 357 bytes
from random import*
p,q=input()
A,V=':/\:',':\/:'
c=sample([(""".------.
|%s.--. |
| %s |
| %s |
| '--'%s|
'------'"""%(n,s,t,n)).split('\n')for s,t in('(\/)',V),(A,V),(A,'(__)'),(':():','()()')for n in'123456789TJQKA'],p*q)
print' | '.join('Player '+`i`for i in range(p))
for i in range(0,p*q,p):print'\n'.join(map(' | '.join,zip(c[i:i+p][0],c[i:i+p][1])))

Try it online!
I have no friggin' idea.

Jelly, 126 bytes
³‘Ḷj“×ṁẹHY»;⁶¤ṫ5W;
2r9;“TJQKA”
“¡ẏ%TZ=ẹaɦAY’ṃ“(\/)_:”s4s2
“E¬ƭḊHẈḢ“ðİ“|e*Ḳ?BḤ’ṃ“. -|1¶'”żÐ€¢FỴ$€p2£j/€Ẋ
¢ssḢµṣ€”1Zj€“ | ”Yµ€ÑY

Try it online!

JavaScript (ES6), 328 ... 312 bytes
Takes input in currying syntax (p)(q). Players are 0-indexed.
p=>g=(q,i=p*q*6,d=[...Array(52).keys(a=`:\\/:,(__),()(),(\\/),:/\\:,:():, | ,
,.3.,|0.--. |,| 1 |,| 2 |,| '--'0|,'3',Player 4`.split`,`)].sort(_=>Math.random()-.5))=>i--+p?g(q,i,d)+a[i%p?6:7]+a[i<0?14:i/p%6|8].replace(/\d/,c=>['TJQKA'[j=x>>2]||j-3,a['3454'[x&=3]],a[x%3],'------',p+i][c],x=d[i%p+p*(i/p/6|0)]):''

Demo

let f =

p=>g=(q,i=p*q*6,d=[...Array(52).keys(a=`:\\/:,(__),()(),(\\/),:/\\:,:():, | ,
,.3.,|0.--. |,| 1 |,| 2 |,| '--'0|,'3',Player 4`.split`,`)].sort(_=>Math.random()-.5))=>i--+p?g(q,i,d)+a[i%p?6:7]+a[i<0?14:i/p%6|8].replace(/\d/,c=>['TJQKA'[j=x>>2]||j-3,a['3454'[x&=3]],a[x%3],'------',p+i][c],x=d[i%p+p*(i/p/6|0)]):''

;(update = _ => O.innerText = f(+P.value)(+Q.value))()
Players <input id=P type=number value=1 onchange="update()"/> Cards <input id=Q type=number value=1 onchange="update()"/> <button onclick="update()">Deal</button>

How?
This is a recursive function, building the output from bottom to top. During the main part in which the cards are drawn, i is initialized to p*q*6 and decremented until it reaches 0. We then draw the header by further decrementing i until it reaches -p.
The ASCII art is split into small pieces stored into the array a[]. The table below describes the content of a[], which makes the rest of the code easier to understand.
 Index | Content    | Description
-------+------------+------------------------------------------------
    0  | ":\\/:"    | bottom of 'diamonds' and 'hearts'
    1  | "(__)"     | bottom of 'spades'
    2  | "()()"     | bottom of 'clubs'
    3  | "(\\/)"    | top of 'hearts'
    4  | ":/\\:"    | top of 'diamonds' and 'spades'
    5  | ":():"     | top of 'clubs'
    6  | " | "      | player separator
    7  | "\n"       | line-feed
    8  | ".3."      | card row #1, "3" --> "------"
    9  | "|0.--. |" | card row #2, "0" --> symbol of card value
   10  | "| 1 |"    | card row #3, "1" --> top of color ASCII art
   11  | "| 2 |"    | card row #4, "2" --> bottom of color ASCII art
   12  | "| '--'0|" | card row #5, "0" --> symbol of card value
   13  | "'3'"      | card row #6, "3" --> "------"
   14  | "Player 4" | header, "4" --> player ID

Formatted and commented
p => g = (                                // p = number of players
  q,                                      // q = number of cards
  i = p * q * 6,                          // i = counter
  d = [...Array(52).keys(                 // d = deck
    a = `:\\/:,(__),...`.split`,`         // a = ASCII art pieces (truncated, see above)
  )].sort(_ => Math.random() - .5)        // shuffle the deck
) =>                                      //
  i-- + p ?                               // if i is greater than -p:
    g(q, i, d) +                          //   do a recursive call and append ...
    a[i % p ? 6 : 7] +                    //   separator or line-feed
    a[i < 0 ? 14 : i / p % 6 | 8]         //   header or card row
    .replace(/\d/, c => [                 //   where digits are replaced with:
        'TJQKA'[j = x >> 2] || j - 3,     //     0: symbol of card value
        a['3454'[x &= 3]],                //     1: top of color ASCII art
        a[x % 3],                         //     2: bottom of color ASCII art
        '------',                         //     3: horizontal border
        p + i                             //     4: player ID
      ][c],                               //
      x = d[i % p + p * (i / p / 6 | 0)]  //   x = current card with: bits 0-1 = color
    )                                     //                          bits 2-5 = value
  :                                       // else:
    ''                                    //   stop recursion

Ruby, 262 bytes
->p,q{a=[*0..51].shuffle
puts ["Player %d"]*p*(d=" | ")%[*1..p],(1..q*6).map{|i|(["'------'
.------.
|%X.--. |
| %s |
| %s |
| '--'%X|".split($/)[i%6]]*p*d%a[i/6*p,p].map{|j|["(\\/):()::/\\:"[u=j%4*4-4,4],":\\/:()():\\/:(__)"[u,4],j/4][i%3]}).tr("01BC","TJQK")}}

Harder to follow, but shorter!
Ruby, 279 bytes
->p,q{puts [*1..p].map{|k|"Player #{k}"}*" | "
a=[*0..51].shuffle
(q*6).times{|i|puts [".------.
|%s.--. |
| %s |
| %s |
| '--'%s|
'------'".split($/)[i%6]]*p*" | "%a[i/6*p,p].map{|j|[":\\/:()():\\/:(__)"[u=j%4*4-4,4],("%X"%(j/4)).tr("01BC","TJQK"),"(\\/):()::/\\:"[u,4]][i%3]}}}

Builds a format for each row, then uses the % operator like sprintf to populate it.
The fact that the card value appears on every 3rd row is handy. Card values are presented in hexadecimal with the digits 01BC substituted to TJQK.
Saved 4 bytes from the suit symbols by considering that the top of diamonds and spades are the same but added 2 back on for the -4 at the end of j%4*4-4 Suit codes are -4 0 4 or 8 where [-4,4] means 4 characters starting the 4th last character in the string.
Could probably save a few more bytes. Having to repeat code for the player identifications is ugly.

PHP, 509 bytes
<?$hu='(\/}';$hv=$dv=':\/:';$du=$su=':/\:';$sv='(__)';$cu=':():';$cv='()()';$q="------";$t=$argv[1];foreach([h,d,s,c]as$a)foreach([2,3,4,5,6,7,8,9,T,J,Q,K,A]as$b)$c[]=[$b,$a];shuffle($c);$h=$a=0;for(;$a<$t;$a++)$e[]="Player $a";$f[]=join(" | ",$e);for($g=$argv[2];$g--;){$p=$i=$k=$l=$m=$r=[];$j=$h+$t;for(;$h<$j;$h++){$n=$c[$h][0];$o=$c[$h][1];$p[]=".$q.";$i[]="|$n.--. |";$k[]="| ${$o.u} |";$l[]="| ${$o.v} |";$m[]="| '--'$n|";$r[]="'$q'";}foreach([p,i,k,l,m,r]as$b)$f[]=join(" | ",${$b});}echo join('
',$f);

Try it online!
This is my first attempt at code golf, so it can probably be improved a lot. I figured I had to start somewhere. :)

Python 2, 382 358 346 338 332 bytes
from random import*
p,n=input()
d=zip([0,1,2,3]*13,'23456789TJQKA'*4)
shuffle(d)
C=""".------.
|%s.--. |
| %s |
| %s |
| '--'%s|
'------'"""
print' | '.join('Player '+`i`for i in range(p))
exec"for l in zip(*[(C%(v,'(:::\/(//\)\):::'[s::4],':((:\_)\/_(/:)):'[s::4],v)).split('\\n')for s,v in d[:p]]):print' | '.join(l)\nd=d[p:]\n"*n

Try it online!

SOGL V0.12, 106 bytes
E⁽⁰⅜║(Ηe─t¦4»\$²‘8n{"1<ω⅛┘‘4n╬¡;4n33žASUjk"TJQKA”+{a;22žF75ž}}'#δ№{ψ⌡≤οc+C}c_.∫:"▓⅛▲ŗ‘Κ⁽e{≤+};H?;lƧ |Γ∙┼;┼

Try it Here!
Card generating:
...‘                     push "(\/):\/::/\::\/::/\:(__):():()()" - the suits
    8n                   split to line lengths of 8 - individual suits
      {                  for each suit
       "...‘               push ".---| .-|   " - a quarter of a suit
            4n             split to line lengths of 4 - [".---", "| .-", "|   "]
              ╬¡           quad palindromize - empty card
                ;          get the suit on top
                 4n        split to line lengths of 4
                   33ž     insert in the card at [3; 3]
                      A    save on variable A - card template
SU                         push "1234567890"
  jk                       remove the first and last digits
    "TJQKA”+               append "TJQKA"
            {         }    for each number - "23456789TJQKA"
             a               load the template
              ;22ž           at [2; 2] insert the current number
                  F75ž       at [7; 5] insert the current number

Shuffling:
'#             push 52
  δ            lower range - [0, 1, ..., 50, 51]
   №           reverse - [51, 50, ..., 1, 0]
    {       }  for each, pushing the current item
     ψ           get a random number from 0 to ToS (inclusive)
      ⌡          that many times
       ≤           put the first item of the stack on the top
        οc+C     prepend that to the variable C, predefined with an empty array

Dealing:
c_              push Cs contents on the stack - the stack is now a mess of cards
  .∫            repeat input times - each player - pushing the current player number
    :             duplicate the number
     "..‘         push "player "
         Κ        prepend "player " to the number
          ⁽       uppercase the 1st letter
           e{  }  repeat 2nd input times
             ≤      put the first stack item on the top
              +     append it to "Player X" vertically (making an array)
;                 get the other copy of the player number
 H?               if POP-1 (aka if it's not 1)
   ;                swap the top 2 items - the current collumn and all the previous ones (by then they've been joined together)
    l               get its (vertical) length
     Ƨ |            push " |"
        Γ           palindromize - [" | "]
         ∙          multiply " | " vertically that length times
          ┼         append it horizontally (to the previous collumns)
           ;┼       append the current collumn

Python 3, 332 Bytes
from random import*
P=lambda x:print(*x,sep=' | ')
R=range
def f(p,c):
 P(f"Player {i}"for i in R(p))
 d=[f".------.,|{n}.--. |,| {a[:4]} |,| {a[4:]} |,| '--'{n}|,'------'".split(",")for a,n in sample([*zip(r':/\:(__) (\/):\/: :/\::\/: :():()()'.split()*13,'A23456789TJQK'*4)],p*c)]
 for i in R(c):
  for t in zip(*d[i::c]):
   P(t)

Java (OpenJDK 8), 784 835 843 826 815 781 775 bytes
String k(String s){return s.replaceAll("...$","\n");}
p->q->{int c=0,l=0,s[]=new int[p*q],i=0,j,t,b;java.util.List e=new java.util.Stack();String v="TJQK",o="",n[]=new String[p*q],x=o;for(;i<p;o+="Player "+i+++" | ",x+=v);o=k(o);for(i=0;i<q;i++){o=k(o+x.replace(v,".------. | "));for(j=0;j<p;j++){do{t=(int)(Math.random()*13)+1;b=(int)(Math.random()*4);}while(e.contains(t+""+v.charAt(b)));e.add(t+""+v.charAt(b));s[c]=b;n[c]=t<2?"A":t<10?""+t:""+v.charAt(t-10);o+="|2.--. | | ".replace("2",n[c++]);}o=k(o);for(j=0;j<p;j++,l++)o+="| "+(s[l]<1?"(\\/)":s[l]<3?":/\\:":":():")+" | | ";o=k(o);for(j=0;j<p;j++)o+="| "+(s[i*p+j]<2?":\\/:":s[i*p+j]<3?"(__)":"()()")+" | | ";o=k(o);for(j=0;j<p;)o+="| '--'2| | ".replace("2",n[i*p+j++]);o=k(k(o)+x.replace(v,"'------' | "));}return o;}

Try it online!
Why the downvote, it complies with the spec

Also, you should create alternate methods instead of creating Function<String,String>: the latter is very, very costly. Both at creation and when used.

I'm assuming the downvote was for the original bugged answer, but the current seems correct, so I've upvoted to neutralize it. Some small things to golf: parenthesis can be removed at n[c]=t<2?"A":t<10?""+t:""+"TJQK".charAt(t-10); for(j=0;j<p;j++){o+=...;l++;} can be for(j=0;j<p;l++,j++)o+=...;; you can return o; instead of System.out.print(o); by using a second Function instead of Consumer; ,y=p*q can be removed and you can use p*q two times directly instead of y. There is without doubt a lot more to golf, but I don't have time to look into that right now..

@KevinCruijssen Actually, no. I downvoted after the first edit for "no effort in golfing" beyond removing spaces and using 1-char variable names. My guess is that Roberto Graham should entirely re-read Tips for golfing in Java. The point is that it indeed complies to the spec of the challenge, but not to the spec of the code-golf tag.

How I know it can be golfed further? I was around 400 bytes when I gave up after seeing this answer, and I estimated around 50 more bytes the rest to finish it. 450 bytes vs. 850, there's barely any golf involved.

s[l]<2?":/\\:":s[l]<3?":/\\:" can be s[l]<3?":/\\:" and s[i*p+j]<1?":\\/:":s[i*p+j]<2?":\\/:" can be s[i*p+j]<2?":\\/:". @OlivierGrégoire And I'm aware it can most likely be almost halved, so I understand the downvote. But this is mostly a lack of experience, and indeed not reading all the tips multiple times. Some of the things in the answer I've done in the past as well, and this isn't a particular easy challenge for Java. Btw, if you have a 400-450 byte answer, why don't you post it as a separated answer then (if significantly different enough)? You'd have my upvote. ;)

732 bytes

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Does it oscillate periodically?
Challenge
Given a list, determine if grouping the list into runs of increasing and decreasing elements will result in a list of equal-sized lists.
In other words, "turning points" of the list are spaced out evenly.
Example
Here's an example: 0, 3, 7, 5, 2, 3, 6
0, 3, 7 increases, 7, 5, 2 decreases, and 2, 3, 6 increases. Therefore this is truthy.
Another example: 1, 4, 6, 8, 5, 3, 5, 7, 9
1, 4, 6, 8 increases, 8, 5, 3 decreases, and 3, 5, 7, 9 increases. Therefore this is falsy.
Rules and Specifications

No adjacent elements will be equal
All numbers can be assumed to be within your language's reasonable number range
You may assume that all numbers are integers, if it helps you golf your submission
This is code-golf, so the shortest answer wins
Input as a list in any reasonable representation and output as any truthy/falsy value. The two values must be consistent.

Test Cases
Input -> Output
1, 3, 5, 8, 6, 4, 2, 3, 5, 7, 6, 4, 2, 5, 7, 9, 6, 4, 2 -> True
1, 3, 5, 7, 6, 4, 5, 7, 9, 8, 6, 4, 2, 3, 5 -> False
2, 3, 6, 4, 2, 3, 7, 5, 3, 4, 6 -> True
3, 6, 4, 8, 5, 7, 3, 5, 2 -> True
8 -> True
1, 3, 5, 7 -> True
4, 5, 7, 6, 8, 9 -> False
6, 4, 2, 3, 5, 4, 2 -> True
8, 5, 3, 2, 4, 6, 5, 3, 2, 5, 7 -> False

Note: You may not assume that all numbers are single digits (unless that is all your language is capable of handling); the test cases reflect that just because it's easier for me to type the cases this way :P Here are a few test cases with numbers outside of that range:
1, 5, 10, 19, 15, 13, 8, 13, 18, 23, 19, 18, 14 -> True
15, 14, 17, 16, 19, 18 -> True
12, 16, 19, 15, 18, 19 -> False

Will the first run always be increasing, or can the input begin with a decreasing run?

@Jordan Could start off decreasing. I will add a test case for that.

Are the groups always complete? For example would 1, 2, 3, 2 be valid input, and if so considered true or false? In that in that example the next value being a 1 would make it true, but a 3 would make it false.

@TomCarpenter That's considered false. They must be all the same length (and thus all complete).

MATL, 10 9 bytes
dZS&Y'da~

Try it online!
Saved one byte thanks to Luis Mendo!
Explanation:
Assume the input is: [0, 3, 7, 5, 2, 3, 6]:
            % Implicit input:                                [0, 3, 7, 5, 2, 3, 6]
d           % Difference between adjacent elements:          [3, 4, -2, -3,  1,  3]
 ZS         % Sign of the differences:                       [1, 1, -1, -1, 1, 1]
   &Y'      % Length of runs of consecutive elements:        [2, 2, 2]
     d      % Difference between the lengths:                [0, 0]
      a     % Any non-zero elements:                         False
       ~    % Negate, to get a truthy value if all are zero: True

Jelly, 6 bytes
IṠŒgAE

Try it online!
Saved 1 byte thanks to Adnan!
How it works

IṠŒgAE  - Full program.

I       - Increments (Deltas).
 Ṡ      - Sign of each. -1 if negative, 0 if null, 1 if positive.
  Œg    - Group runs of adjacent elements.
    A   - Absolute value. Vectorizes. This maps -1 and 1 to the same value.
     E  - Are all equal?

While golfing, I discovered some cool, longer alternatives: IṠŒgL€E, IṠŒrṪ€E (uses run-length-encode instead).

I think IṠŒgḂE should save a byte

@Adnan Can A (absolute value) substitute Ḃ or is there a trick I don't get regarding Ḃ?

Any function that unifies 1 and -1 to the same number should suffice

Wolfram Language (Mathematica), 38 bytes
Equal@@(1^Differences@#~SplitBy~Sign)&

Try it online!
Explanation
Equal@@(1^Differences@#~SplitBy~Sign)&  (* Input:                {3, 6, 4, 8, 5, 7, 3, 5, 2} *)

          Differences@#                 (* Take differences:     {3, -2, 4, -3, 2, -4, 2, -3} *)
                       ~SplitBy~Sign    (* Split by sign:        {{3}, {-2}, {4}, {-3}, {2}, {-4}, {2}, {-3}} *)
        1^                              (* Raise to power of 1:  {{1}, {1}, {1}, {1}, {1}, {1}, {1}, {1}} *)
Equal@@                                 (* Check equal:          True *)

Equal@@(1^Split@Sign@Differences@#)& is 2 bytes shorter, and Equal@@Im@Split@Sign@Differences@#& is 1 more byte shorter than that.

And now that I'm thinking about complex numbers, using Arg instead of Sign saves another byte.

Octave, 54 50 bytes
@(x)nnz(unique(diff(find([diff(diff(x)>0) 1]))))<2

Try it online!
Explanation
@(x)nnz(unique(diff(find([diff(diff(x)>0) 1]))))<2

@(x)                                                % Define anonymous function
                               diff(x)              % Deltas (consecutive differences)
                                      >0            % Positive? Gives signs
                          diff(         )           % Deltas between signs
                         [                1]        % Append 1 to "close" last group
                    find(                   )       % Indices of nonzeros
               diff(                         )      % Deltas. Gives group lengths
        unique(                               )     % Remove duplicates
    nnz(                                       )    % Number of nonzeros. Gives length
                                                <2  % If 1 or 0: input is periodic

R, 36 bytes
function(n)!sd(rle(sign(diff(n)))$l)

diff computes the successive differences, then sign squishes those down to ±1. rle then run-length encodes them. All the elements of this rle should be the same, i.e. the vector has standard deviation zero. ! then produces the correct logical output.

C (gcc), 143 140 138 136 135 132 bytes

Saved three bytes; using a variable r to store the function's return boolean instead of terminating using return.
Saved two bytes; golfing int A[] to int*A (using a pointer instead of an array).
Saved two bytes thanks to Steadybox; golfing f(int*A,int a) to f(A,a)int*A;.
Saved a byte; golfing if(d!=... to if(d-....
Saved three bytes; golfing ;j++...j+1 to ;...++j.

j,d,e,l,m,r;f(A,a)int*A;{for(d=A[0]>A[1],r=1,j=m=l=0;j-~-a;){l++;if(d-(e=A[j]>A[++j]))d=e,j--,r*=l>=(m=!m?l:m),l=0;}r*=-~l==m||m<1;}

Try it online!
Defines a function f which looks at every element in the list but the last and determines this element's relation to the next element in the list. The number of consecutive equal comparisons is stored the first time the relation flips, any runs after the initial run that differ in length to the stored length result in a falsy output. At the end, the second-to-last element's relation to the last element's is looked at so that it matches the rest of the list.

You can use f(A,a)int*A; instead of f(int*A,int a).

05AB1E, 8 7 bytes
¥0.SγaË

Try it online!
-1 thanks to Adnan.

¥0.SγaË should save a byte

What is a I can't find it in the docs. is_letter(a)???

yep, that is correct

@Adnan ahhh... weird idea, good idea.

Pyth, 11 bytes
qFlM.g._k.+

Try it here.

Python 2, 107 105 103 97 96 94 91 bytes
lambda l:len({sum(g)**2for k,g in groupby(map(cmp,l[:-1],l[1:]))})<2
from itertools import*

Try it online!
Python 3, 102 100 97 bytes
lambda l:len({len([*g])for k,g in groupby(x>y for x,y in zip(l,l[1:]))})<2
from itertools import*

Try it online!

you can use {...} instead set(...) to save 3 bytes

Husk, 7 bytes
EmLġ±Ẋ-

Try it online!
How this works

EmLġ±Ẋ-  ~ Full program.

     Ẋ   ~ Map over pairs of adjacent elements.
      -  ~ With subtraction (this computes the deltas)
   ġ     ~ Group using equality predicate.
    ±    ~ Sign.
 mL      ~ Get the lengths.
E        ~ Are all equal?

Some cute alternatives:
εġLġ±Ẋ-
εüLġ±Ẋ-

Python 2, 96 bytes
import re
def f(x):exec"x=map(cmp,x[1:],x[:-1]);"*2;re.match('.([^1]*)(-?1, \\1)*9',`x+[9]`)<0<_

Try it online! Output via exit code: crash (1) is falsey, clean exit (0) is truthy.
Python 2, 106 bytes
def f(x):d=map(cmp,x[1:],x[:-1]);l=len(d);s=(d+[0])[0];k=(d+[-s]).index(-s);print((k*[s]+k*[-s])*l)[:l]==d

Try it online!

I am not certain, though (...)[:l]<d may be the inverse of (...)[:l]==d.

Desmos, 82 bytes
f(l)=0^{mod(k/k[1],1).total}
L=D(D(l))
k=[1...L.length][LL=1]
D(l)=sign(l[2...]-l)

Try It On Desmos!
Try It On Desmos! - Prettified
Explanation
D(l)=sign(l[2...]-l): Takes the consecutive differences of the input list l, and takes the sign of the resulting differences.
L=D(D(l)): Applies the function D described above 2 times on l. The first difference will output a list (which I will denote as A) that, for each value of the original list l[i] for some i in the range [1,l.length-1], does the following:

If l[i]<l[i+1], A[i] will be 1. In other words, if l increases from l[i] to the next element, then it is denoted in the new list as 1.
If l[i]>l[i+1], A[i] will be -1. In other words, if l decreases from l[i] to the next element, then it is denoted in the new list as -1.

Note that we don't have to consider the case where l[i]=l[i+1], because that is guaranteed not to happen as per the specs:

No adjacent elements will be equal

The second difference outputs a list (denoted as B below) that does the following for each value in A, A[i], for some i in the range [1,A.length-1] (remember that the first difference is denoted as A):

If A[i]=A[i+1], then B[i] will be 0. In terms of l, what this checks for is if l[i], l[i+1], and l[i+2] are all either increasing or decreasing.
If A[i]<A[i+1], then B[i] will be 1. In terms of l, what this checks for is if it decreases from l[i] to l[i+1], but increases from l[i+1] to l[i+2]. In other words, this will check for transitions from a decreasing run to an increasing run.
Similarly, if A[i]>A[i+1], then B[i] will be -1. In terms of l, what this checks for is if it increases from l[i] to l[i+1], but decreases from l[i+1] to l[i+2]. In other words, this will check for transitions from an increasing run to a decreasing run.

k=[1...L.length][LL=1]: Filters the range [1...L.length] based on whether L*L is 1. This essentially obtains a list of indices at which L is either 1 or -1, and removes the indices where it is 0. What this achieves is that it will find the indices of the "turning points".
f(l)=0^{mod(k/k[1],1).total}: Divides each element of k by the first element k[1], and then takes the fractional part of the resulting quotients.
If the "turning points" are spaced out evenly, then this will result in a list of all 0's. Otherwise, at least one element will be a decimal number.
The total of this list is 0 only if the list only contains 0's, and nothing else. Otherwise, the total will be some number greater than 0. In other words, the total is 0 only if the elements are spaced out equally.
The last part is that, 0^0 is 1, will 0^n for some positive number n is 0. We can take advantage of this by using the total we obtained, and raising 0 to the power of the total. Recall that if the "turning points" are all spaced out evenly, then the total will be 0. This will cause 0^{mod(k/k[1],1).total} to be 1. Otherwise, if they aren't spaced out equally, the total is greater than 0, so 0^{mod(k/k[1],1).total} will be 0.

JavaScript (ES6), 81 bytes
This seems too long. I'm probably missing something here... Returns either true or undefined.
f=(a,p=1)=>a.every((n,i)=>!i|!(1/(y=a[i+1]))|!(i%p)^y>n^a[i-1]>n)||a[p]&&f(a,p+1)

Looks for a period 0 < p < a.length such that all direction changes occur every p elements.
Test cases

f=(a,p=1)=>a.every((n,i)=>!i|!(1/(y=a[i+1]))|!(i%p)^y>n^a[i-1]>n)||a[p]&&f(a,p+1)

console.log(f([1, 3, 5, 8, 6, 4, 2, 3, 5, 7, 6, 4, 2, 5, 7, 9, 6, 4, 2])) // -> True
console.log(f([1, 3, 5, 7, 6, 4, 5, 7, 9, 8, 6, 4, 2, 3, 5])) // -> False
console.log(f([2, 3, 6, 4, 2, 3, 7, 5, 3, 4, 6])) // -> True
console.log(f([3, 6, 4, 8, 5, 7, 3, 5, 2])) // -> True
console.log(f([8])) // -> True
console.log(f([1, 3, 5, 7])) // -> True
console.log(f([4, 5, 7, 6, 8, 9])) // -> False
console.log(f([15, 14, 17, 16, 19, 18])) // -> True
console.log(f([19, 15, 14, 17, 18, 17, 16, 19, 20])) // -> True

Haskell, 79 78 77 bytes
import Data.List
g s|h:t<-(1<$)<$>group(zipWith(<)s$tail s)=all(==h)t
g _=1<3

Try it online!
Given a list s, zipWith(<)s$tail stests for each element whether it is smaller than its successor, e.g. s=[2,3,6,4,2,3,7,5,3] yields [True,True,False,False,True,True,False,False]. Then group runs of the same elements together: [[True,True],[False,False],[True,True],[False,False]]. To check whether all those lists have the same length, replace their elements with 1 (see this tip) yielding [[1,1],[1,1],[1,1],[1,1]] and check if all elements in the tail t of this list equal the head h: all(==h)t.
This approach does not work for singleton lists, but because those are always true, we can handle them in their own case: g[_]=1<3.

g s=length(nub$map(1<$)$group$zipWith(<)s$tail s)<2 seems to work for 68 bytes.

R, 57 bytes
function(x){d=diff
sum(rle(d(which(!!d(d(x)>0))))$v^0)<2}

Try it online!

Japt, 15 bytes
ä- mg ò¦ mÊä¥ e

Try it online!
Explanation
ä- mg ò¦ mÊä¥ e                                                  [0,3,7,5,2,3,6]
ä-                // Difference between neighboring elements     [-3,-4,2,3,-1,-3]
   mg             // Get the sign of each element                [-1,-1,1,1,-1,-1]
      ò¦          // Partition between different elements        [[-1,-1],[1,1],[-1,-1]]
         mÊ       // Get the length of each element              [2,2,2]
           ä¥     // Check for uniqueness                        [true,true]
              e   // Return true if all elements are truthy      true

Clojure, 70 63 bytes
#(<(count(set(map count(partition-by pos?(map -(rest %)%)))))2)

Returns true or false. The original answer was a bit silly.

Haskell (Lambdabot), 59 bytes
g(map(1<$).group.ap(zipWith(<))tail->h:t)=all(==h)t;g _=1<3

Based on @Laikoni's answer

Nice, I didn't know Lamdabot had ViewPatterns enabled. There is a space missing in g_=1<3.

@Laikoni Me neither, but I actually went to #haskell and tested it

Python 2, 110 99 bytes
-11 bytes thanks to @Lynn
d=input()
exec"d=map(cmp,d[:-1],d[1:]);"*2
x=[i+1for i,e in enumerate(d)if e]
for i in x:i%x[0]>0<q

Try it online!

You can save some bytes by computing the double differences as exec"d=map(cmp,d[:-1],d[1:]);"*2

Java (OpenJDK 8), 437 302 256 188 bytes
a->{int i=0,g=0,x=0,l=0;String d="";for(;i<~-a.length;d+=a[0].compare(a[i+1],a[i++])+1);for(String s:d.split("(?<=(.))(?!\\1)"))if(g++<1)x=s.length();else if(s.length()!=x)l++;return l<1;}

Try it online!

Java (OpenJDK 8), 135 bytes
a->{Integer i=0,c,d=0,p=0,r=0;for(;++i<a.length;)d+=(i<2|(c=i.signum(a[i-1]-a[i]))<0?d<0:d>0)?c:p==0|p==-d?c-(p=d):1-(r=1);return r<1;}

Try it online!
Explanations
a->{                    // int array
 Integer i=0,c,d=0,p=0,r=0;
                        // variable definitions, use Integer to abuse static calls
 for(;++i<a.length;)    // Loop from 1 till length - 1
  d+=                   // Change d
   (i<2                 // First iteration?
     |(c=i.signum(a[i-1]-a[i]))<0?d<0:d>0
   )                    // Or do c and d have the same sign?
    ?c                  // then increase the magnitude of d.
    :p==0|p==-d         // else we're in a u-turn. Is it the first? Or is the magnitude the same as previously?
     ?c-(p=d)           // assign the new magnitude with sign to p and reset d to -1 (if was positive) or 1 (if was negative)
     :1-(r=1);          // else just do r=1 (technically: "add 1-1=0 to d" as well)
 return r<1;            // return whether there were wrong amplitudes.
}

Ruby, 57 bytes
->a{!a.each_cons(2).chunk{|x,y|x>y}.uniq{|*,x|x.size}[1]}

Try it online!

Japt, 9 bytes
Outputs false for truthy and true for falsey.
äÎòÎmÊäÎd

Try it (footer negates the output) or run all test cases
äÎòÎmÊäÎd     :Implicit input of array                                    > [0,3,7,5,2,3,6]
ä             :Consecutive pairs                                          > [[0,3],[3,7],[7,5],[5,2],[2,3],[3,6]]
 Î            :  Reduced by the sign of their differences (1 or -1)       > [-1,-1,1,1,-1,-1]
  ò           :Partition between elements that return true (not zero)
   Î          :  Get the sign of their difference                         > [[-1,-1],[1,1],[-1,-1]]
    m         :Map
     Ê        :  Length                                                   > [2,2,2]
      ä       :Consecutive pairs                                          > [[2,2],[2,2]]
       Î      :  Reduced by the sign of their differences                 > [0,0]
        d     :Any truthy?                                                > false

Husk, 7 bytes
Λ≡gẊo±-

Try it online!

Vyxal, 5 bytes
¯±Ġȧ≈

Try it Online!
Port of Jelly answer.
How?
¯±Ġȧ≈
¯     # Get the deltas (consecutive differences) of input
 ±    # Get the sign (implicit vectorization)
  Ġ   # Group consecutive identical items
   ȧ  # Absolute value (implicit double-vectorization)
    ≈ # All equal?

Factor, 49 bytes
[ [ trends check-lengths t ] [ tuple? ] recover ]

Try it online!
There is a lot to unpack here. First, Factor (nearly!) has the perfect word for this problem, trends, which splits a sequence into its rising, falling, and stable parts. This question guarantees no two adjacent elements will be equal, so we don't need to worry about receiving any stable trends in the result.
The problem is, for some unfathomable reason, if the sequence has only one trend, trends returns a single trend object instead of a sequence with a single trend object in it. Thus when we attempt to see if the lengths of the trends are all equal, we'll get an error that length can't be applied to a non-sequence if there is only a single trend.
Next, instead of saying something like [ length ] map all-eq?, Factor has a word in its (exposed) compiler named check-lengths that throws an error if the lengths of a sequence are not all equal. So check-lengths is capable of failing in two different ways: either it'll end up calling length on a non-sequence, or it'll throw an error if the lengths of its input are not all the same.
Enter recover, one of Factor's exception handling words. It calls the first quotation (which will simply return t if no errors are encountered) and calls the second quotation with the error on top of the stack if the first quotation encounters an error. Inside this quotation, all we need to do is check whether the error is a tuple or not, because calling length on a non-sequence produces an actual error tuple while check-lengths throws a simple string error if the lengths are unequal.


text:
Make an n-Juggler
I've been really interested with sequences that follow the property
\$a(n+1) = a(n - a(n))\$
recently, so here's another question about these sequences.  In particular we are concerned with sequences from the integers to the natural numbers.
A periodic sequence with the above property is an n-Juggler if and only if it contains exactly n distinct values.  For example the following sequence is a 2 juggler
... 2,2,1,2,2,1,2,2,1,2,2,1,2,2,1,2,2,1,2,2,1,2,2,1,2,2,1,2,2,1,2,2,1,2,2,1 ...

because it only contains the numbers 1 and 2.
An example of a three juggler would be
... 3,5,3,5,1,5,3,5,3,5,1,5,3,5,3,5,1,5,3,5,3,5,1,5,3,5,3,5,1,5,3,5,3,5,1,5 ...

because it juggles 1, 3, and 5.
Task
Given n > 1 as input, output any n-Juggler.
You may output a sequence in a number of ways, you can

output a function that indexes it.
take an additional input of the index and output the value at that index.
output a continuous subsection of the sequence that, with the given property uniquely determines the sequence.

This is code-golf so answers are scored in bytes with less bytes being better.

Are we allowed to print the sequence indefinitely?

@Mr.Xcoder Normally I would say yes, but since these sequences are infinite in both directions, I have to hesitantly say no.  (If you offer a compelling argument I could easily change my mind on this) If you can find a way to print in both directions that would be fine.

@WheatWizard How about a list into which values are indefinitely appended and prepended and after each addition the list is printed?

@Steadybox Sure that sounds fine.  Probably not the easiest way to do it though.

What does "with the given property uniquely determines the sequence" mean?

It seems the sequnces follow a(n+1) = a(n-a(n)), and not +

@Zgarb Sorry I made another mistake in the equation TFeld is right it should be minus.  I must be off it today or something...

@xnor It means that given the subsection you can use the property to derive all the other members of the sequence, for example if you know 2,2,1 is in the sequence you can find every other member.  Basically it means that it is a subsection that only exists in one sequence with the property.

I also think "uniquely determines the sequence" is a bit confusing, even after your explanation. How about outputting a subsection that can be repeated indefinitely both ways to construct the actual sequence? Like the repetend of a rational number.

@aditsu I choose the definition there very carefully,  it's a little more lenient in someways and stricter than others than the definition you suggest.  I would like to make it as clear as possible but that is the idea I want to use.

Except we don't really understand what it means... Btw, is my idea acceptable as an output choice? In fact.. the additional input thing might end up being easier.

@aditsu No your idea is not sufficient, for example 2,2 when repeated infinitely makes a valid sequence but it could also be a part of ... 2,2,1,2,2,1,2,2,1 ... thus it doesn't uniquely determine a sequence.

2,2 uniquely determines the …2,2,2,2… sequence (1-juggler) and does NOT determine the …2,2,1,2,2,1… sequence (2-juggler).

@aditsu 2,2 does not uniquely determine any sequence, its part of both of the sequences.

Yes it does: repeat 2,2 once → 2,2,2,2, repeat again → 2,2,2,2,2,2, etc. There's absolutely no way to get a 1 from repeating 2,2. The sequence you get is always unique.

Let us continue this discussion in chat.

It looks like the property is no more.

Pyth, 5 bytes
t+*%E

Try the 2, 3, 4 Jugglers.
Receives two numbers, N and I, separated by a newline and in this order. I is the index into the sequence.
This uses a quite simple formula: N - 1 + N * (I % N). Its validity was confirmed by the OP.

CJam, 9
How about this?
q~1$,=)*(

Try it online
Input is n i where n is the main input and i is the index you want to get the value for.
Explanation:
q~    read and evaluate the input (n and i)
1$    copy n
,=    basically this is a modulo (i%n) that avoids a negative result for negative i
)*    increment, then multiply by n
(     decrement

Python 2, 20 bytes
lambda n,i:i%n*n+n-1

Try it online!
Same principle as Mr. Xcoder's answer

Should principal not rather read principle?

@JonathanFrech... yeah..

Haskell, 17 bytes
n!i=i`mod`n*n+n-1

Try it online!
Another answer using Mr. Xcoder's idea. I wouldn't be able to answer the question otherwise to be honest. :P

Vyxal, 4 bytes
%›*‹

Try it Online!

without the -1 your function obeys $a(n)=a(n-a(n))$.

Java 8, 15 bytes
n->i->i%n*n+n-1

Boring port of @Mr.Xcoder's Pyth answer.
Try it here.

Jelly, 5 bytes
Ɠ%×+’

Try it online!
Port of Mr. Xcoder's approach. The index I is in STDIN, N is an argument.

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/