text:
Is this number a factorial?
The Task
Given a natural number as input, your task is to output a truthy or falsey value based on whether the input is a factorial of any natural number. You can assume that the input number will always be in the range of numbers supported by your language, but you must not abuse native number types to trivialize the problem.
Standard Loopholes apply.

Input
You'll be given a natural number (of type Integer or similar).
You can take input in any way you want except assuming it to be in a predefined variable. Reading from file, console, dialog box (prompt), input box etc. is allowed. Input as function argument is allowed as well!

Output
Your program should output a truthy or falsey value based on whether the input number is a factorial of any natural number.
Make sure that your truthy/falsey values are consistent for all inputs, i.e, if you are using pair of 1 and 0 to denote truthy and falsey values respectively, then your program must output 1 for all inputs that should have truthy values and 0 for all inputs that should have falsey values.
You can take output in any way you want except writing it to a variable. Writing to file, console, screen etc. is allowed. Function return is allowed as well!
Your program must not produce errors for any input!

Test Cases
Input     Output

1         Truthy (0! or 1!)
2         Truthy (2!)
3         Falsey
4         Falsey
5         Falsey
6         Truthy (3!)
7         Falsey
8         Falsey
24        Truthy (4!)
120       Truthy (5!)

Winning Criterion
This is code-golf, so the shortest code in bytes wins!

If the language supports only numbers in the range {0,1}, can I expect the input to always be 1?

@eush77 Abusing native number types to trivialize a problem is forbidden by default.

is 4! a truthy?

Question: Why aren't you using the I/O defaults?

@CalculatorFeline Didn't know they existed, if you still want to know the answer :-P Sorry

Brachylog, 1 byte
ḟ

Try it online!
Explanation
ḟ is a built-in that asserts the following relation: its  output is the factorial of its input. We simply give it a set output and see whether it suceeds or not with a variable input.

It's perfectly fine to take input via Command Line Arguments.

Why does it output true. and not simply true?

@BetaDecay That's because it's the way it's printed in Prolog (this has to do with the fact that true. is a statement and true is not)

It's a trivial solution, but it's clever because of the way prolog works.

I'm not sure which character encoding has ḟ in its table of 256 bytes

Brachylog uses UTF-8 so this is 3 bytes

@Nayuki This one, which is custom

First custom languages, then custom encodings... code golf is dead. We've completely subverted the whole point of these fun problems in the first place

@Alexander Custom encodings are irrelevant to whatever problem you're talking about. I could use any "existing" encoding instead and it would still be 1 byte. It would just be much less readable.

Congratulations on winning! :)

ECMAScript Regex, 733⚛ 690⚛ 158 119 118 92 bytes

dropped 1 byte (119 → 118) using a trick found by Grimmy that can futher shorten division in the case that the quotient is guaranteed to be greater than or equal to the divisor
dropped 26 bytes (118 (117) → 92) thanks to Grimmy in collaboration with H.PWiz. I've finally analyzed, commented, and proved this version.

My interest in regex has been sparked with renewed vigor after over 4½ years of inactivity. As such, I went in search of more natural number sets and functions to match with unary ECMAScript regexes, resumed improving my regex engine, and started brushing up on PCRE as well.
I'm fascinated by the alienness of constructing mathematical functions in ECMAScript regex. Problems must be approached from an entirely different perspective, and until the arrival of a key insight, it's unknown whether they're solvable at all. It forces casting a much wider net in finding which mathematical properties might be able to be used to make a particular problem solvable.
Matching factorial numbers was a problem I didn't even consider tackling in 2014 – or if I did, only momentarily, dismissing it as too unlikely to be possible. But last month, I realized that it could be done.
As with my other ECMA regex posts, I'll give a warning: I highly recommend learning how to solve unary mathematical problems in ECMAScript regex. It's been a fascinating journey for me, and I don't want to spoil it for anybody who might potentially want to try it themselves, especially those with an interest in number theory. See this earlier post for a list of consecutively spoiler-tagged recommended problems to solve one by one.
So do not read any further if you don't want some advanced unary regex magic spoiled for you. If you do want to take a shot at figuring out this magic yourself, I highly recommend starting by solving some problems in ECMAScript regex as outlined in that post linked above.
This was my idea:

 The problem with matching this number set, as with most others, is that in ECMA it's usually not possible to keep track of two changing numbers in a loop. Sometimes they can be multiplexed (e.g. powers of the same base can be added together unambiguously), but it depends on their properties. So I couldn't just start with the input number, and divide it by an incrementally increasing dividend until reaching 1 (or so I thought, at least).

 Then I did some research on the multiplicities of prime factors in factorial numbers, and learned that there's a formula for this – and it's one that I could probably implement in an ECMA regex!

After stewing on it for a while, and constructing some other regexes in the meantime, I took up the task of writing the factorial regex. It took a number of hours, but ended up working nicely. As an added bonus, the algorithm could return the inverse factorial as a match. There was no avoiding it, even; by the very nature of how it must be implemented in ECMA, it's necessary to take a guess as to what the inverse factorial is before doing anything else.
The downside was that this algorithm made for a very long regex... but I was pleased that it ended up requiring a technique used in my 651 byte multiplication regex (the one that ended up being obsolete, because a different method made for a 50 byte regex). I had been hoping a problem would pop up that required this trick: Operating on two numbers, which are both powers of the same base, in a loop, by adding them together unambiguously and separating them at each iteration.
But because of the difficulty and length of this algorithm, I used molecular lookaheads (of the form (?*...)) to implement it. That is a feature not in ECMAScript or any other mainstream regex engine, but one that I had implemented in my engine. Without any captures inside a molecular lookahead, it's functionally equivalent to an atomic lookahead, but with captures it can be very powerful. The engine will backtrack into the lookahead, and this can be used to conjecture a value which cycles through all possibilities (for later testing) without consuming characters of the input. Using them can make for a much cleaner implementation. (Variable-length lookbehind is for most uses at least equal in power to molecular lookahead, but the latter tends to make for more straightforward and elegant implementations. Molecular lookahead may also be able to do things in loops that aren't possible with variable-length lookebehind.)
So the 733 and 690 byte lengths do not actually represent ECMAScript-compatible incarnations of the solution – hence the "⚛" after them; it's surely possible to port that algorithm to pure ECMAScript (which would increase its length quite a bit) but I didn't get around to it... because I thought of a much simpler and more compact algorithm! One that could easily be implemented without molecular lookaheads. It's also significantly faster.
This new one, like the previous, must take a guess at the inverse factorial M, cycling through all possibilities and testing them for a match. It divides N by 2 to make room for the work it needs to do, and then seeds a loop in which it will repeatedly divide the input by a divisor that starts at 3 and increments up to M-1.* (As such, 1! and 2! can't be matched by the main algorithm, and must be dealt with separately.) The divisor is kept track of by adding it to the running quotient; these two numbers can be unambiguously separated because, assuming M! == N, the running quotient will continue to be divisible by M until it equals M.
*But it later turned out that starting the divisor at M-1, and decrementing down to 3, can result in a shorter regex. This was part of golfing 118 → 92 bytes.

 This regex does division-by-a-variable in the innermost portion of the loop. The division algorithm is the same as in my other regexes (and similar to the multiplication algorithm): for A≤B, A*B=C if any only if C%A=0 and B is the largest number which satisfies B≤C and C%B=0 and (C-B-(A-1))%(B-1)=0, where C is the dividend, A is the divisor, and B is the quotient. (A similar algorithm can be used for the case that A≥B, and if it is not known how A compares to B, one extra divisibility test is all that is needed.)

So I love that the problem was able to be reduced to even less complexity than my golf-optimized Fibonacci regex, but I do sigh with disappointment that my multiplexing-powers-of-the-same-base technique will have to wait for another problem that actually requires it, because this one doesn't. It's the story of my 651 byte multiplication algorithm being supplanted by a 50 byte one, all over again!
With no further ado, here's the regex:
True/false version (92 bytes):
^(((x+)\3+)(?=\3\3\2$)(x(?=\3+(x*))(?=\5+$)(?=((x+)(?=\5\7*$)x)\6*$)\3+(?=\5\7$))*\3xx|x?)x$
Try it online!
Return inverse factorial or no-match (109 bytes):
^(?=((x(x*))\2+)(?=\2\2\1$)(x(?=\2+(x*))(?=\5+$)(?=((x+)(?=\5\7*$)x)\6*$)\2+(?=\5\7$))*\2xxx$)(\3|xx)?x|^xx?$ (relies on ECMAScript no-empty-optional behavior)
Try it online!
Return inverse factorial or no-match, in ECMAScript + \K (103 bytes):
^(((x(x*))\3+)(?=\3\3\2$)(x(?=\3+(x*))(?=\6+$)(?=((x+)(?=\6\8*$)x)\7*$)\3+(?=\6\8$))*x\Kxx(\K\4)?|x?)x$ (relies on ECMAScript no-empty-optional behavior)
Return inverse factorial or no-match, in ECMAScript + (?*) (103 bytes):
When adapted to molecular lookahead, this regex can match \$3!\$ in a straightforward way:
^(?=(?*(x+))(\1*)(?=\1\1\2$)(x(?=\1+(x*))(?=\4+$)(?=((x+)(?=\4\6*$)x)\5*$)\1+(?=\4\6$))*\1xxx$)\1|^xx?$
Return inverse factorial or no-match, in ECMAScript + (?*) + \K (99 bytes):
^(?*(x+))(\1*)(?=\1\1\2$)(x(?=\1+(x*))(?=\4+$)(?=((x+)(?=\4\6*$)x)\5*$)\1+(?=\4\6$))*xxx\K\1$|^xx?$
And the free-spaced version with comments:
# Match factorial numbers in the domain ^x*$
^                           # N = tail = input
(
    ((x+)\3+)(?=\3\3\2$)    # \3 = conjectured inverse factorial of N if N >= 4! = 24;
                            # \2 = N/2 - \3; assert tail is divisible by \3 and by 2;
                            # assert tail is divisible by a number >= 6;
                            # tail = N/2 + \3;
                            # Note that if N = 3! = 6, \3 will behave differently,
                            # because sticking to the pattern, we'd need \2=0, which
                            # is of course impossible, because we must have \2 >= \3.
                            # However, when N=6, \3=1 happens to result in a match after
                            # zero loop iterations.
    # The loop is seeded: X = N/2; I = \3 - 1; tail = X + I + 1
    # The loop will divide X by the numbers in the range \3-1 downward to 3, inclusive.
    # Since we don't divide by \3 itself, and already divided by 2, if N is factorial,
    # the end result of these divisions will be X = \3.
    (                       # Main loop
        x                   # tail = tail-1 = X + I
        (?=\3+(x*))         # \5 = tail % \3 = I; assert X >= \3
        (?=\5+$)            # assert X is divisible by I; if \3=1, then \5=0,
                            # and the main loop will exit after zero iterations
        (?=
            (               # \6 = tail / \5 = (X+I)/I = X/I + 1
                (x+)        # \7 = \6-1 = X/I; assert X/I >= 1
                (?=\5\7*$)
                x
            )
            \6*$
        )
        \3+(?=\5\7$)        # Prepare the next iteration of the loop: X = \7; I -= 1;
                            # tail = X + I + 1;
                            # Assert that the tail difference is divisible by \3, i.e.
                            # that, with our previous values of X and I:
                            #      X + I - (X/I + I-1 + 1)
                            #    = X/I*(I-1) is divisible by \3
                            # Since I is coprime with I-1, if X was divisible by \3
                            # but X/I is not, then X/I*(I-1) will not be either, so this
                            # indirectly asserts that X/I, our new X, is divisible by \3.
                            # The initial value of X was asserted to be divisible by \3
                            # before the loop started, so by induction, every new value
                            # of X will be asserted to be divisible by \3. This is
                            # important because we use modulo by \3 to recover the value
                            # of I at the beginning of each loop iteration.
                            # And if N = \3! and the previous of I=2 and X was able to be
                            # divided by 2, this will force this iteration of the loop to
                            # fail, and the loop will exit with the values of X and I
                            # backtracked to their values before this iteration, i.e.
                            # with X = \3 and I = 2.
    )*
    \3xx                    # assert tail = \3 + 2 + 1, meaning when the loop finished
                            # we ended up with X = \3 and I = 2
|
    x?                      # match N=1 and N=2, which the main algorithm can't
)
x$

The full history of my golf optimizations of these regexes is on github:
regex for matching factorial numbers - multiplicity-comparing method, with molecular lookahead.txt
regex for matching factorial numbers.txt (the one shown above)
Optimized for returning the inverse factorial
The above algorithm has the quirk of happening to match \$3!\$ by coincidence, yielding a false inverse factorial value of \$1\$ instead of \$3\$. This complicates turning the regex into one that returns the inverse factorial as a match.
The below algorithm is cleaner in that it straightforwardly matches \$3!\$ with the correct inverse factorial value. It does however result in a longer true/false regex.
True/false version – returns inverse factorial minus 1 in \1 (96 bytes):
^(x*)(?=x(x\1)*$)((?=\2*(x*)(?=\2)\4(x+))(?=\5+$)(?=((x*)(?=\5\7*$)x)\6*$)\2*(?=x\4\6$)\1)*\1x?$
Try it online! - true/false
Try it online! - return value in \1
Return inverse factorial or no-match (103 bytes):
^(?=(x*)(?=x(x\1)*$)((?=\2*(x*)(?=\2)\4(x*))(?=\5+$)(?=((x*)(?=\5\7*$)x)\6*$)\2*(?=x\4\6$)\1)*\1x?$)x\1
Try it online!
Return inverse factorial in \1 or no-match, in ECMAScript + (?*) (97 bytes):
^(?*(x(x*))\1*$)\2((?=\1*(x*)(?=\1)\4(x*))(?=\5+$)(?=((x*)(?=\5\7*$)x)\6*$)\1*(?=x\4\6$)\2)*\2x?$
Return inverse factorial or no-match, in ECMAScript + \K (101 bytes):
^(x*)(?=x(x\1)*$)((?=\2*(x*)(?=\2)\4(x(x*)))(?=\5+$)(?=((x*)(?=\5\8*$)x)\7*$)\2*\4(?=x\7$)\K\6)*\1x?$
Return inverse factorial minus 1 or no-match, in ECMAScript + \K (98 bytes):
^(x*)(?=x(x\1)*$)((?=\2*(x*)(?=\2)\4(x+))(?=\5+$)(?=((x*)(?=\5\7*$)x)\6*$)\2*(?=x\4\6$)\1)*x?\K\1$
# Match factorial numbers in the domain ^x*$ and return the inverse factorial as the match
^                           # N = tail = input
(?=
    (x*)                    # \1 = conjectured inverse factorial - 1; tail -= \1
    (?=x(x\1)*$)            # \2 = conjectured inverse factorial; assert \2 divides N;
                            #      assert N >= 2 * \2;
                            # If N=1 or N=2, then \2 will be unset (having experienced 0
                            # iterations of its mini-loop) and \1=0 or \1=1, respectively
    # The loop is seeded: X = N; I = \1; tail = X - I
    # The loop will divide X by the numbers in the range \2-1 downward to 2, inclusive.
    # We don't divide by \2 itself, so if N is factorial, the end result of these
    # divisions will be X = \2 - 1.
    (
        (?=
            \2*(x*)(?=\2)   # \4 = tail % \2 = \2-I; assert tail >= \2
            \4(x*)          # \5 = \2-\4 = I
        )
        (?=\5+$)            # assert X is divisible by I
        (?=
            (               # \6 = tail / \5 = (X-I)/I = X/I - 1
                (x*)        # \7 = \6-1
                (?=\5\7*$)
                x
            )
            \6*$
        )
        \2*(?=x\4\6$)\1     # Prepare next iteration of loop: X = \6+1; I -= 1;
                            # tail = X - I;
                            # Assert that, with our previous values of X and I:
                            #      (X - I) - (1 + \2-I + X/I - 1)
                            #    = X - \2 - X/I                   is divisible by \2
                            # Assuming X was already divisible by \2, this asserts
                            # X/I is also divisible by \2. The initial value of X was
                            # asserted to be divisible by \2, so by induction, every
                            # new value of X will be asserted to be divisible by \2.
                            # This is important because we use modulo by \2 to recover
                            # the value of I at the beginning of each loop iteration.
                            # And if I = 1, this iteration of the loop will fail
                            # because in this case,
                            #      1 + \4 + \6 > tail
                            #      \2-I + X/I > X - I
                            #      \2 > 0
                            # and the loop will exit with I = 1.
                            # But note that if N = \2!, then when we reach I = 1, and
                            # thus have X = \2 and tail = \2 - 1, this iteration of the
                            # loop will have already failed at its beginning due to the
                            # assertion that tail >= \2.
    )*
    \1x?$                   # assert tail = \1 = \2-1, meaning when the loop finished we
                            # ended up with X = \2 and I = 1,
                            # or tail = \1+1 (what would be \2), which can only happen if
                            # \2 is unset and N=1 or N=2 and the loop did 0 iterations.
)
x\1                         # return \1 + 1 as a match; don't use \2 because it will be
                            # unset in the case of N=1 or N=2

Jelly, 4 bytes
Œ?IE

Not the shortest Jelly answer, but it's rather efficient.
Try it online!
How it works
Œ?IE  Main link. Argument: n

Œ?    Yield the n-th permutation of the positive integers, without the sorted tail.
      For 120, this yields [5, 4, 3, 2, 1], the tail being [6, 7, 8, ...].
  I   Increments; compute all forward differences.
      For 120, this yields [-1, -1, -1, -1].
   E  Check if all differences are equal.

Because us code golfers care about efficiency.

It's a dramatic complexity improvement at the cost of one byte and it's a clever use of a built-in if I may say so myself.  ¯\(ツ)/¯

Interestingly, this returns true for 0, while @LeakyNun's 3 byte answer, while much slower in general, correctly returns false for 0. Are extra bytes needed to return false for 0 in an efficient-execution-time answer?

@Deadcode Checking for 0 would require two extra bytes. If not sure if the OP's definition of "natural numbers" includes 0 or not. The test cases don't...

Jelly, 3 bytes
!€ċ

Try it online!
1 for yes, 0 for no.
How it works
!€ċ  argument as z
!€   [1!, 2!, 3!, ..., z!]
  ċ  count the number of occurrence of z

JavaScript (ES6), 30 29 28 bytes
Expects a positive integer. Returns -1 for falsy and -2 for truthy.

f=(n,k=2)=>n>1?f(n/k,k+1):~n

console.log(1,  '-->',f(1))   // Truthy (0! or 1!)
console.log(2,  '-->',f(2))   // Truthy (2!)
console.log(3,  '-->',f(3))   // Falsey
console.log(4,  '-->',f(4))   // Falsey
console.log(5,  '-->',f(5))   // Falsey
console.log(6,  '-->',f(6))   // Truthy (3!)
console.log(7,  '-->',f(7))   // Falsey
console.log(8,  '-->',f(8))   // Falsey
console.log(24, '-->',f(24))  // Truthy (4!)
console.log(120,'-->',f(120)) // Truthy (5!)

Note: This function supports pretty large inputs (you should read this as: 'pretty large for JS'). It should work safely up to 253 - 1. It will fail for sure starting at N = 121,645,100,408,831,992, this input being rounded to 19! = 121,645,100,408,832,000 because of its IEEE-754 encoding. There may be other false positive results before 121,645,100,408,831,991 because of rounding errors, but I don't know for sure.

Nice - really like the use of ~ at the end.

Can you edit so I can undownvote? (If you want to know why I downvoted, it's because I forgot about this question's unusual I/O rules.)

@Arnauld Undownvoted.

Python 3, 39 38 bytes
f=lambda n,i=1:n>1and f(n/i,i+1)or n<1

A recursive function taking an integer, n, returning a boolean value inversley representing the result (truthy: False, falsey: True)
Try it online!
Repeatedly divides n by i, with an initial value of 1, until the remainder is less than or equal to 1 then tests if that remainder is less then 1, only factorials will end with a remainder equal to 1, and < is a byte shorter than ==.

@ovs we have been restricted to a two consistent outputs. That, unfortunately, returns 1 for all factorials except 1 for which it returns True.

Java 8, 46 bytes
i->{int j=1,c=0;for(;j<i;j*=++c);return j==i;}

This is based on Roman Gräf's entry that I was able to knock a dozen or so bytes off of.  I would have suggested it there but I don't have enough reputation to comment yet!  My modified test runner code:
import java.util.function.Function;
import java.util.stream.IntStream;

public class IsFactorial {
    public static Function<Integer, Boolean> isFactorial = i->{int j=1,c=0;for(;j<i;j*=++c);return j==i;};
    public static int[] truthyCases = {1,2,6,24,120};
    public static int[] falsyCases = {3,4,5,7,8};
    public static void main(String[] args){
        System.out.println(
            IntStream.of(truthyCases).allMatch(i->isFactorial.apply(i)) &&
            IntStream.of(falsyCases).allMatch(i->!isFactorial.apply(i)));
    }
}

Retina, 50 38 bytes
12 bytes saved thanks to @Neil by combining shortening the loop and by getting rid of the ;
.+
1¶$&$*
+`^(1+)¶(\1)+$
1$1¶$#2$*
¶.$

Try it online!
Outputs 1 for true and 0 for false.
.+ matches the entire number
1¶$&$* replacing it with 1 followed by a newline and the match converted to unary
The remaining program divides the unary number in the bottom line by successively increasing positive integers, kept track in the top line, while it is possible to do so.
+` loop until string remains same

^(1+)¶(\1)+$ match the top line many 1s and a multiple of it many 1s on the bottom line and replace it with
1$1¶$#2$* the top line many 1s with another 1, that is, increasing the number represented by the top line by 1, followed by the newline and the number of matches of the top line in the bottom line (ie. count of matches of the second capturing group) many 1s, that is, dividing the bottom number by the top number

Once it is no longer possible to do so,
¶.$ give the number of matches of this regex, ie. does there exist a lone 1 on the bottom line, which only happens if the number is a factorial

If no-crash/crash is allowed instead of truthy/falsy values, then I can get 36 34 bytes.
^
1¶
{`.+$
$*
^(1+)¶(\1)+$
1$1¶$#2

This goes by the same approach, but combines the $* into the third and fourth lines. The third line onward is a part of the same loop, { is short for +( where the ( groups the remaining lines into the loop. Factorials end in the program breaking out of the loop, while non-factorials get stuck in the loop forever until Retina throws an OverflowException caused by the last replacement failing thus having the bottom in unary instead of in decimal, and the first replacement of the loop converts the bottom line from decimal to unary, so it blows up quickly.

Save a byte by removing the 1 as it is implied when $* is at the end of the replacement.

Better still, combine the $* with the other two lines.

Try it online!

@Neil I was looking for a way to collapse the loop into just one statement, thanks for showing me the way :)

I'm impressed that you found a way to crash Retina conditionally. :)

Can you add an explanation?

C++, 102 100 92 Bytes
#include<cmath>
int a(int n){int i=n,j=0;for(;i;)j|=lround(exp(lgamma(i--+1)))==n;return j;}

Loops through all the values from 0 to n and calculates the factorial and then checks if it's equal to n.
Thanks Christoph! (saved 8 bytes)

Hi! Welcome to PPCG! Nice first answer! Good luck for the future!

Nice first answer ! You can save a few byte like this: int a(int n){int i=n,j=0;for(;i;)j|=lround(exp(lgamma(i--+1)))==n;return j;}. lround and lgamma are already C++11 so could simply #include<cmath>. Maybe you can even further improve my suggestions :)

05AB1E, 4 bytes
L!QO

Try it online!
Explanation
L      # range [1 ... input]
 !     # calculate factorial of each
  Q    # compare with input for equality
   O   # sum

Wouldn't you need to duplicate the input first because L pops its input? Also, Å! gives you a list of factorial less than or equal to the input.

@NeilA. Fortunately the input is popped again if there are not enough arguments on the stack for an operation, so I don't need D here. Good catch about Å!. I always forget about the list-commands. It won't save any bytes, but it is more efficient for sure.

I didn't know about input being popped again...that sure could save a lot of bytes.

@NeilA. It is a fairly new feature. It was added less than a month ago I think.

Haskell, 43 26 bytes
f n=elem n$scanl1(*)[1..n]

Try it online!

Saved 17 bytes, thanks to Laikoni

f n=elem n$scanl1(*)[1..n] is ridiculous inefficient but shorter.

Isn't there some rule about code efficiency?

None that I am aware of. [tag:code-golf] asks for a solution in as few bytes as possible without any efficiency statements. Also on my machine the function works up to 40430 without noticeable delay.

I meant something along the lines of "the solution should terminate within a reasonable timeframe", but I guess it fits the requirements either way. Thanks!

Nice and simple. I thought I could do better with division—say, divMod by [1..] successively until reaching a zero remainder with a quotient of 1 (factorial) or a nonzero remainder (non-factorial), but it doesn’t seem to be the right approach. I did find this cute 46-character solution, though: f|let x%n=mod n x==0&&(x+1)%div n x||n==1=(1%).

Check out Laikoni's answer for division based approach.

Haskell, 38 bytes
m#n=n<2||mod n m<1&&(m+1)#div n m
(2#)

Try it online! Example usage: (2#) 24. Returns True or False.
This is the shortest I could get while still being very efficient. Even for numbers as large as
145183092028285869634070784086308284983740379224208358846781574688061991349156420080065207861248000000000000000000

the result is immediately given. The solution works by dividing the input n by m = 2,3,4,5,... until either the result is one or n is not divisible by m.
For the shorter but incredible inefficient 26-byte solution which computes n! for inputs that are not factorials look here.

Fourier, 40 39 bytes
I~Q1~N(i^~i*N~N{Q}{1~Xo}N>Q{1}{1~X0o}X)

Try it on FourIDE!
Basically multiplies the number N by an increasing amount until N is either equal to (output 1) or greater than (output 0) the input.
Explanation Pseudocode:
Q = Input
N = 1
While X != 1
    i += 1
    N = N*i
    If N = Q Then
        Print 1
        X = 1
    End If
    If N > Q Then
        Print 0
        X = 1
    End If
End While

Japt, 8 6 bytes
ol x¥U

Try it online!
This outputs 0 for false and 1 for true.
Explanation
 ol x¥ U
Uol x==U
Uo       # Create the range [0 ... input]
  l      # Replace each element by its factorial
     ==U # Compare each element to the input (yielding 1 if equal and 0 otherwise)
    x    # And sum the result

I really should add a "contains" built-in :P

Oh hey, you could change aU ¦J to x¥U (map each X to X==U and sum), though it won't work on TIO.

Fails for 2 becuase o will only give you [0,1]. Here's a fix with a 1 byte saving.

MATL, 5 bytes
t:Ypm

Try it online!
Explanation
t     % Implicit input. Duplicate
:     % Range from 1 to that
Yp    % Cumulative product
m     % Ismember. Implicit display

APL (Dyalog Unicode), 5 6 7 bytes
Golfed a byte by changing ×/ to ! thanks to Erik the Outgolfer
⊢∊!∘⍳

Try it online!
Explanation
    ⍳                      Range of numbers from 1 to argument, 1 2 3 4 .. n
   !                       Factorial; 1! 2! 3! 4! .. n!
⊢∊                         Is the right argument a member of this list?

Cumulative sum?

@LeakyNun Fixed

One extra byte in GNU APL 1.2 N∊×\⍳N←⎕ How does this take an argument? I don't see n anywhere. Is this a Dyalog-specific thing?

@Arc676 My solution is a train and you call it like so: (⊢∊(×/⍳)) right_argument as you can see in the TIO link. And the ⊢ refers to the right argument.

Notes: AGL will save you a byte; ⊢∊×\ä⍳. The "correct" (but longer) solution would be 0=1|!⍣¯1; "Is the inverse factorial an integer?"

I think ×\ can be !.

@EriktheOutgolfer How didn't anyone think of that. It is pretty obvious!

@EriktheOutgolfer Thanks, updated.

C++ (clang), 51 47 bytes
-4 bytes thanks to Grimmy
Recursion wins out as far as golfing goes.
47 bytes, with floating point and a global variable:
int i;int f(double n){return n>1?f(n/++i):i=n;}
Try it online!
double is used instead of float because otherwise it'd start giving false positives around 11! (everything from 39916798 to 39916802 would be identified as factorial).
This takes advantage of global variables being initialized (in the case of the integer i, to zero).
i=n casts a double floating point value to int. Any n<1 will be rounded down to 0 (falsey). A value of 1 (truthy) will result if and only if n==1 exactly.
The function cleans up after its change to the global variable upon finishing its recursion, by setting it to 0 or 1 with i=n. Which of those it is makes no difference; an value of 1 will merely result in the initial division by 1 being skipped the next time the function is invoked.
49 bytes, with floating point:
int f(double n,int i=2){return n>1?f(n/i,i+1):n;}
Try it online!

51 bytes, zero is true:
int f(int n,int i=2){return n<2?!n:n%i|f(n/i,i+1);}
This sacrifices quite a lot of speed for 1 byte of savings. Replace the | with || to make it fast, due to short-circuit evaluation of the logical OR.
Try it online! (51 byte slow version)
Try it online! (52 byte fast version)
Ungolfed slow version:
int isFactorial(int n, int i=2)
// returns 0 for true, and nonzero for false
{
    if (n < 2) // same as "if (n==0 || n==1)" in our natural number input domain
    {
        if (n==0)
            return 1; // not factorial
        else // n==1
            return 0; // is factorial (could be either 0! or 1!)
    }

    // Because any nonzero value represents "false", using "|" here is equivalent
    // to "||", provided that the chain of recursion always eventually ends. And
    // it does always end, because whether or not "n" is factorial, the "n / i"
    // repeated division will eventually give the value of zero or one, satisfying
    // the above condition of termination.
    return (n % i) | isFactorial(n / i, i+1);
}

Ungolfed fast version:
int isFactorial(int n, int i=2)
// returns 0 for true, and nonzero for false
{
    if (n < 2) // same as "if (n==0 || n==1)" in our natural number input domain
    {
        if (n==0)
            return 1; // not factorial
        else // n==1
            return 0; // is factorial (could be either 0! or 1!)
    }

    if (n % i != 0)
        return 1; // not factorial
    else
        return isFactorial(n / i, i+1);
}

There are many ways to rearrange this.
52 bytes, nonzero is true:
int f(int n,int i=2){return n<2?n:n%i?0:f(n/i,i+1);}
Try it online!
52 bytes, zero is true:
int f(int n,int i=2){return!n?1:n%i?n-1:f(n/i,i+1);}
Try it online!

Before resorting to recursion, I tried making some iterative versions, and they came close.
54 bytes, nonzero is true:
int f(int n){for(int i=2;n>1;)n=n%i?0:n/i++;return n;}
Try it online!
54 bytes, zero is true (based on Roman Gräf's Java 8 submission):
int f(int n){int a=1,i=0;for(;a<n;a*=++i);return a-n;}
Try it online!
But as Grimmy pointed out, with floating point it can be shorter, even when done iteratively...
50 bytes, nonzero is true, floating point:
int f(double n){for(int i=2;n>1;)n/=i++;return n;}
Try it online!

Now, for the bottom of the barrel, recursive versions with no n==0 handling (I consider these invalid, because 0 is a natural number, and any definition in which it is not makes for "natural numbers" of very limited use). In the below versions, the infinite recursion of f(0) either triggers a segfault due to overflowing the stack, or with compilers that optimize it to iteration, loops endlessly:
48 bytes, zero is true:
int f(int n,int i=2){return n%i?n-1:f(n/i,i+1);}
Try it online!
48 bytes, zero is true (based on Hagen von Eitzen's 33 byte C (gcc) submission):
int f(int n,int e=0){return n%++e?n-1:f(n/e,e);}
Try it online!

50
EDIT: 49, without recursion.

Back to recursion for 48. And you probably won’t like this, but 44 by using a global var.

Perl 5, 31 bytes
$a=<>;$a/=++$i while$a>1;exit$a

Input is taken via STDIN, output is given via exit code (1 for factorial, 0 for non-factorial).
The input is divided by successive integers until it's either 1 or some fraction less than one, which is truncated into the result.

-5 bytes TIO

Perl 6, 29 bytes
{($_,{$_/++$}...2>*).tail==1}

Test it
Expanded:
{   # bare block lambda with implicit parameter ｢$_｣

  (              # generate a sequence

    $_,          # starting with the input

    {
      $_ / ++$   # divide previous element by an ever increasing number
                 # 1,2,3,4,5,6,7,8 ... *
    }

    ...          # keep generating until

    2 > *        # 2 is greater than what was generated
                 # ( 1 or a fractional number )

  ).tail == 1    # check if it ended at 1
}

17 bytes: {$_∈[\*] 1..$_}. Another interesting approach is 2>*.polymod(1..*).sum.

C (gcc), 33 bytes
e;f(n){n=n%++e?n==!(e=0):f(n/e);}

Note that some authors define "natural number" as positive integer. Hence I don't care that f(0) causes an infinite recursion.

Try it online!

Can be dropped to 32 bytes: Try it online! or 31 bytes by returning nonzero for false: Try it online!

><>, 24 22 bytes
-2 bytes thanks to @Aaron
I'm trying a new language (since my Mathematica licence expired…)
01\{=n;
?!\$1+:@*:{:}(

Try it online, or at the fish playground
Assumes the input number is already on the stack, and returns 0 or 1. It works by multiplying together the first n numbers until that stops being less than the input, and then printing 1 if it equals the input, and 0 if it doesn't.

You could transform you v>\n<^ into \\n/ ; see here

@Aaron, that's brilliant, thank you!

setlX, 32 bytes
f:=n|=>exists(x in{0..n}|n==x!);

Creates a function called f where your use your potential factorial as parameter.
It works with arbitrary integer size but it's fairly inefficient.

(by the way: this is my first participation at a programming puzzle)

R, 28 22 bytes
scan()%in%gamma(1:171)

Try it online!

Make it a 22 bytes full program?

I'm worried I'll start using this stuff in production code.

C# (.NET Core), 68 bytes
bool f(System.Numerics.BigInteger n,int k=2)=>n<2||n%k<1&f(n/k,k+1);

Try it online!
Not the shortest solution, but works with really big numbers. The TIO link includes an example with 10000!.
Here is a shorter version that uses int which has a maximum value of 2147483647.
C# (.NET Core), 45 bytes
bool f(int n,int k=2)=>n<2||n%k<1&f(n/k,k+1);

Try it online!
Credit to @KevinCruijssen for golfing 3 bytes in total from both answers!

The && can be golfed to &, and the trailing ; doesn't have to be counted for lambda functions. Also, can't the ulong k=2 be uint k=2 in your 50-byte answer?

Good catch on the & vs &&. I thought I was getting a stack overflow, but it seems to work afterall. ulong is 64 bits while uint is 32. It looks like others are using int so maybe I'll just use that for the short version. With regards to the trailing ;, these are full functions, not lambdas, so I think I need include them?

That's really strange how .NET can resolve / and % between ulong and uint, but not ulong and int. Didn't know that :)

@Oliver - With double you start to see rounding at some point - for example, 24! and 120! fail. While System.Numerics.BigInteger has the most precision, int is the shortest answer :)

It should be noted that this returns the wrong result for zero. And @KevinCruijssen's golfing of && to & results in a slowdown very similar to the golfing of || to | in my C++ answer (they both work in C++ and the former is only 3% slower), but of course the latter won't work in C# due its strict separation of boolean and integer types. In any case, I like that one of the versions handles very big numbers.

@Deadcode - You are right about 0 :) Based on the examples in the challenge, I interpreted "natural numbers" to mean 1,2,... I agree that in the real world, it is better to use the short circuiting && operator. But this is code golf ;) Glad you like the 10000! example!

Julia 1.0, 26 bytes
x->x in Base._fact_table64

Factorial is implemented as a lookup table in Julia, so lets just see if our value is in the table. Accurate for Int64, would be wrong for factorials that require a larger Integer type to represent.
Try it online!

-1 byte: x->x∈Base._fact_table64

Vyxal, 3 bytes
Þ!c

Try it Online!
Updated to 2.16.0
This checks if the input is in an infinite list of factorials. Now you're probably wondering "but what if it isn't in the factorial list? A linear search won't ever terminate it'll just keep on going!" Well Vyxal is smart enough to know that in strictly ascending infinite lists of numbers, you stop once you reach a number bigger than what you're searching for.

Cubix, 24 bytes
U0O@1I1>-?1u>*w;W;@Orq)p

Try it online
Cubified
    U 0
    O @
1 I 1 > - ? 1 u
> * w ; W ; @ O
    r q
    ) p

We start by pushing 1, Input, 1 onto the stack.  These will be our index, our target, and our accumulator, respectively.
We then loop.  At each iteration, we subtract the accumulator from the input. If the result is 0, we're done, so we push 1, Output, and exit.  If it's negative, we've gone too far, so we push 0, Output, and exit.  Otherwise, we see
;p)*rq;
;         Pop the difference off the stack.
 p)       Move the index to the top of the stack and increment it.
   *      Multiply the accumulator by the index to get the next factorial.
    rq;   Put the stack back in the right order.

Mathematica, 20 bytes
!FreeQ[Range[#]!,#]&

other version to test big numbers
(see comments)
Range[10^3]!~MemberQ~#&

tests up to 1000!

As I understand the question, if Mathematica is capable of taking 1001! as an input then this doesn't meet the spec.

You could even save three bytes while making it valid for all inputs. Just replace 10^3 with #  ; you could save another byte with using Range@#

@Julien Klugethen searching for 1243234 would take forever...

@Peter Taylor why would you ask if 1001! is factorial?  ;-)

Why would you not?

@Jenny_mathy but this is not relevant. The challenge didn't gave any performance restrictions. Theoretically it works like charm. It just takes a long time and it saves bytes so why don't?

ok...done.........

I think you can save another byte by replacing Range[#] with Range@# :)

Looks like you can save yet another byte with infix syntax: !Range@#!~FreeQ~#&.

Equally short:  MemberQ[Range[#]!, #] &

More computationally efficient, but also longer:  (a = Range[#]!) \[Union] {#} == a & where \[Union] should be counted as a single byte.

Neim, 3 bytes
Uses some builtins added after this challenge was created.

Explanation:
Example input: 6
     Inclusive range [1 .. input]
      [[1, 2, 3, 4, 5, 6]
     Factorial each
      [[1, 2, 6, 24, 120, 720]]
     Check that the [cycled] input is in the list
      [1]

Try it!
Neim, 8 bytes
Γ₁)

Explanation:
Example input: 6
         Inclusive range [1 .. input]
          [1, 2, 3, 4, 5, 6]
 Γ        For each...
           Inclusive range [1 .. element]
            [[[1], [1, 2], [1, 2, 3], [1, 2, 3, 4], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5, 6]]
           Product
            [1, 2, 6, 24, 120, 720]
           Check for equality with
    ₁       the first line of input
            [[0, 0, 1, 0, 0, 0]]
      )   End for each
         Select largest element
          [1]

Try it!

TI-BASIC, 13 bytes
sum(Ans=seq(X!,X,1,69

Input is an integer in Ans.
Output is 1 if the input is a factorial, 0 if not.
Due to precision in = checks being limited to 10 decimal places, this program will produce erroneous answers for numbers whose length is \$>10\$ digits.
Explanation:
        seq(X!,X,1,69  ;generate a list of all factorial numbers that
                       ;  TI-BASIC can store
    Ans=               ;equality check of the input against all members,
                       ;  1 if true, 0 if false
sum(                   ;sum the elements in the list
                       ;leave the result in Ans
                       ;implicit print of Ans

Examples:
720:prgmCDGF27
               1
25:prgmCDGF27
               0

Note: TI-BASIC is a tokenized language.  Character count does not equal byte count.

cQuents, 3 bytes
?$!

Try it online!
As I said in another question, cQuents is made for this.
?   # Query (Outputs if in the sequence)
 $! # Factorial

Desmos, 34 bytes
max(\left\{[1,...,f]!=f,0\right\})

Try it in Desmos!
It simply finds the factorial of each number in an array from 0 to f (our input), and checks if f is in there using bounds.

JavaScript (ES6), 71 bytes
This takes in input as function argument and alerts the output. Outputs 0 for falsey and 1 for truthy.
f=n=>n?n*f(n-1):1;g=(n,r=0,i=0)=>{while(i<=n){r=f(i)==n|r;i++}alert(r)}

Explanation
The program consists of two functions, f and g. f is a recursive factorial-computing function, and g is the main function of the program. g assumes to have a single argument n. It defines a default argument r with a value of 0 and another default argument with a value of 0. It, then, iterates over all the Integers from 0 to n, and, in each iteration, checks whether the function f applied over i (the current index) equals n, i.e. whether n is a factorial of i. If that happens to be the case, r's value is set to 1. At the end of the function, r is alerted.
Test Snippet
(Note: The snippet outputs using console.log() as nobody like too many of those pesky alert()s.)

f=n=>n?n*f(n-1):1;g=(n,r=0,i=0)=>{while(i<=n){r=f(i)==n|r;i++}console.log(r)}

g(1)
g(2)
g(3)
g(4)
g(5)
g(6)
g(7)
g(8)
g(24)
g(120)

Eval might be shorter than using a code block.

@Downgoat How should I do that? Sorry if it's too obvious! :P

PHP, 32 Bytes
prints -2 for true and -1 for false

for(;1<$argn/=++$x;);echo~$argn;

Try it online!

echo$a&1 would work in PHP too (see my JS answer).

@Arnauld the other both bitwise operations should work in JS too

Yup. Or even ~$a if -1 / -2 are acceptable outputs.

-3 bytes: for(;1<$argn/=++$x;);echo~$argn;.

Is -1 really falsy in PHP? (I have never used this language)

@LuisMendo NO but we can take any values so long they are consistent to all inputs. It saves 1 Byte see the history. Here are a list which values are really false in PHP http://php.net/manual/en/types.comparisons.php

I understood the challenge as requiring a truthy and a falsy value, but you may be right in assuming that any two distinct values will do

@LuisMendo If I am not right I can do a rollback to the previous version.

@JörgHülsermann Maybe ask the OP?

Java 8, 59 bytes
i->{for(int j=1,c=0;j<=i;j*=++c)if(j==i)return 1;return 0;}

Testcode
import java.util.function.IntFunction;
import java.util.stream.IntStream;

public class IsFactorial
{
    public static IntFunction<Integer> isFactorial = i->
    {
        for(int j=1,c=0;j<=i;j*=++c)
            if(j==i)return 1;return 0;
    };

    public static int[] truthyCases = {1,2,6,24,120};
    public static int[] falsyCases = {3,4,5,7,8};

    public static void main(String[] args)
    {
        System.out.println
        (
            IntStream.of(truthyCases)
                .allMatch(i->isFactorial.apply(i)==1)
            && IntStream.of(falsyCases)
                .allMatch(i->isFactorial.apply(i)==0)
        );
    }
}

Charcoal, 24 bytes
ＮβＡ⟦⟧γＷ¬﹪βＬ⊞ＯγβＡ÷βＬγβ⁼β¹

Try it online! Prints - for true and nothing for false. Note: Link is to verbose form for ease of explanation.

QBIC, 21 19 bytes
[:|q=q*a~q=b|_x1}?0

Explanation
[:|     Start a FOR loop from 1 to n
q=q*a   q starts as 1 and is multiplied by the FOR loop counter
        consecutively: q=1*1, *2, *3, *4 ... *n
~q=b|   If that product equals n
_x1     Then quit, printing a 1
}       Close the IF and the FOR
?0      If we're here, we didn't quit early and didn't find a factorial, print 0

Previously
[:|q=q*a┘c=c+(q=b)}?c

Explanation:
[:|         Start a FOR loop from 1 to n
q=q*a       q starts as 1 and is multiplied by the FOR loop counter
            consecutively: q=1*1, *2, *3, *4 ... *n
┘           Syntactic line break
c=c+        c starts out at 0 and then keeps track of
    (q=b)       how often our running total == n
}           Closes the FOR-loop
?c          Print c, which is 0 fir non-factorials and -1 otherwise.

C, 42 41 38 bytes
-3 bytes by @KritixiLithos!
m;f(float n){for(;n>1;n/=++m);m=n==1;}

Try it online!

Looks like 41 bytes to me ...

your TIO link shows a different program than the one in your post, and that one is 39 bytes

@HagenvonEitzen fixed

@ConorO'Brien fixed

-3 bytes by changing m=n==1 to m=n, and then another -3 bytes by using recursion. But you should identify this as "C (gcc)" not just C, because the omit-return hack doesn't work in all C compilers, e.g. clang.

Befunge-98, 39 38 bytes
&1s #;:30g%;@.;#0_30g:1+30p/:1-#;!#1_;

Try it online!
Funge storage is only byte-sized, so the input number has to be kept on stack.
&1s #;:30g%;@.;#0_30g:1+30p/:1-#;!#1_;
&1s                                     n = read(), k = 1
     ;:30g%;     _                      S: if n % k != 0 goto Z
                  30g      /            n /= k
                     :1+30p             k += 1
                            :1-  !  _   if n != 1 goto S
                                ;  1    push(1), goto P
                0                       Z: push(0)
            @.;                         P: print()

you can use 1sX instead of 100p at the beginning as long as you swutch all the other get and put coordinates to 30 instead of 00 to save a byte.

@MistahFiggins thanks!

Ruby, 34 bytes
->a{x=1;(1..a).any?{|y|(x*=y)==a}}

Try it online!

C#, 43 40 bytes, 41 bytes fallback
Uses a for loop to increment a number to divide the input by until the variable containing the input is no longer more than one. Returns false if the input is a factorial, true otherwise. The expression type is Func<dynamic, System.Func<dynamic, bool>> and it can take the same input for both calls. In case that isn't allowed, the fallback answer is System.Func<dynamic, bool>.
Short Answer
Try it online!
m=>s=>{for(s=2f;m>1;)m/=s++;return m<1;}

Fallback
Try it online!
m=>{for(var s=2f;m>1;)m/=s++;return m<1;}

I unfortunately think this solution is incorrect. Perhaps there was some confusion regarding integer division? Here is a link to some failing test cases: Try it online!

@dana you're right, I didn't account for m/s being between 1 and 2 and ending up 1 for a non-factorial.

Haskell, 42 41 bytes
f 0=1
f a=a*f(a-1)
i x=elem x f<$>[1..x]

sample ghci output:
λ> i 0
False
*Main
λ> i 1
True
*Main
λ> i 2
True
*Main

Welcome to PPCG and golfing in Haskell in particular! You can save a byte with f<$>[1..x] instead of map f[1..x].

Templates Considered Harmful, 99 bytes
Fun<Ap<Fun<If<Eq<A<1>,T>,T,Eq<Rem<A<1>,A<2>>,F>,Ap<A<0>,Div<A<1>,A<2>>,Add<A<2>,T>>,F>>,A<1>,I<2>>>

Try it online!
Ungolfed:
Fun<Ap<Fun<If<Eq<A<1>, T>,
              T,
              Eq<Rem<A<1>, A<2>>, F>,
              Ap<A<0>, Div<A<1>, A<2>>, Add<A<2>, T>>,
              F>>,
       A<1>, I<2>>>

Divides by 2, 3, 4… until hits 1 or non-zero remainder.

T-SQL 143 Bytes
create function a(@ int)
returns int begin
declare @a int=1,@b int=1
while @b<@
select @b*=@a,@a+=1
return case @b when @ then 1 else 0 end
end

Playing code golf with SQL gives me results like when I really golf!
Analysis:
create function a(@ int)
returns int begin

Ugh why do I have so many required characters to create a SQL function
declare @a int=1,@b int=1

We need a variable for our current factorial value, and a variable for the iteration to multiply by.
while @b<@

While our current factorial value is less than our input value, keep iterating through the loop.
select @b*=@a,@a+=1

Multiply our factorial value by the iteration value, and add one to the iteration value for the next loop.
return case @b when @ then 1 else 0 end

If our factorial value equals our input value, then it's going to return 1 for true, and if it's not, then that means it's not a factorial value and it's false.
end

Pyt, 5 bytes
←Đř!∈

Explanation:
←           Get input and put on stack
 Đ          Duplicate top of stack
  ř         Push [1,...,top of stack] to stack
   !        Calculate element-wise factorial of the array
    ∈       Is input in factorial array?

SmileBASIC, 37 bytes
INPUT N
WHILE N>1A=A+1N=N/A
WEND?N==1

Divides N by increasing numbers until N is less than or equal to 1.
If N was a factorial, it will be 1 at the end.
Examples:
8 (÷1)-> 8 (÷2)-> 4 (÷3)-> 4/3 (÷4)-> 1/3 (end)
6 (÷1)-> 6 (÷2)-> 3 (÷3)-> 1 (end)

C++, 87 77 bytes
(I'm aware this is a bit old, but I figured I'd try my luck since the current C++ answer is at 92 bytes)
int f(int a){a=a?a*f(a-1):1;}int c(int a,int b=0){a=f(b)-a?a-b?c(a,b+1):0:1;}

The function for the check is c, the f function is purely to calculate the factorial
Ungolfed with comments:
int f(int a)
{
    // In some systems the last expression evaluated will be
    // the return value, this is utilizing that, as it assigns
    // a to a, and if that is 0, then the last espression will
    // have been 1, else it will be a * f(a-1)
    a=a ? a*f(a-1) : 1;
}

int c(int a,int b=0)
{
    // This works in the same way but over 2 levels
    // If f(b)==a then a=f(b)-a is 0, which means it'll
    // evalute 1, truthy, but if it's not zero, then it
    // Checks if a==b, if yes then it's 0, falsy because
    // we've checked all numbers, and if it's not 0, then
    // it calls c again with b+1
    a = f(b) - a ? a - b ? c(a,b+1) : 0 : 1;
}

Try it online (Thanks to @Jonathan Frech for the 77 bytes and link)
I found this recursive method much more shorter than a loop, especially with the default argument that stores the counter.

Welcome to PPCG! You might want to add a Try it online! link.

77 bytes.

@JonathanFrech Thank you for the improvement, but I'm unsure of how it works exactly, I put some comments to explain what I think it is, could you check if this is it? Also there is one specific thing I don't understand if my rational is correct, which is that you assign a=f(b)-a on the beginning, so how can you call c(a,b+1) without any problems? I would have thought the value of a would be lost after the first iteration

@FilipeRodrigues To my knowledge, it is simply an undefined behaviour exploitation with regards to gcc on some processors. The registers for the last assigned integer and the integer return value just happen to be the same in some (!) cases. Regarding your question, a= is the very last thing that will happen, so it cannot override c's argument. I actually do not think that there is a sequencing issue of any kind. If you simply add an return a; the a= should simply be an obfuscation.

For the sake of fairness, I also want to say that @Deadcode provided the TIO link and the test wrapper.

Alchemist, 265 264 bytes
_->a+In_b+q
q+b->q+h+c
q+0b->r
r+h->r+b
r+0h->s
s+i->s+j+m
s+0i->t
t+a->t+d
t+0a->u
u+d->u+a+n
u+0d->v
v+n->v+h
v+0n+m->t
v+0n+0m->p
p+a->p
p+0a->w
w+h->w+a+f
w+j->w+i
w+0j+0h->i+x
x+b+f->x
x+0b+0f->Out_"1"
x+0b+f->Out_"0"
x+b+0f->y
y+b->y
y+0b->z
z+c->z+b
z+0c->q

Outputs 1 if it's a factorial and 0 otherwise: Try it online or test the first n factorials!
Ungolfed
The non-determinism comes from the rules
w+h->w+a+f     # s6 +  tmp -> s6 + accum + factorial
w+j->w+i       # s6 + counter_copy -> s6 + counter
w+0j+0h->i+x   # s6 + 0counter_copy + 0tmp -> counter + s7

which could be serialised to
w+h->w+a+f   # s6 +  tmp -> s6 + accum + factorial
w+0h->o      # s6 + 0tmp -> _s6
o+j->o+i     # _s6 +  counter_copy -> _s6 + counter
o+0j->i+x    # _s6 + 0counter_copy -> counter + s7

such that the tmp-atom will be duplicated first and only then counter_copy renamed to counter and incremented:
Try it online! (see debugging output)
But it should be clear that this non-determinism will not change the result of the complete computation:
# initialize accumulator & read input
_ -> accum + In_input + s0

# duplicate the input
s0 +  input -> s0 + tmp + input_copy
s0 + 0input -> s1

s1 +  tmp -> s1 + input
s1 + 0tmp -> s2

# duplicate the counter
s2 +  counter -> s2 + counter_copy + multiplier
s2 + 0counter -> s3

# duplicate the accumulator: factor <- accum
s3 +  accum -> s3 + dup
s3 + 0accum -> s4

s4 +  dup -> s4 + accum + factor
s4 + 0dup -> s5

s5 + 0factor +  multiplier -> s3   # while multiplier > 0:
s5 +  factor -> s5 + tmp           #   add factor: tmp += factor

# when "loop" is done, cleanup accum and continue
s5 + 0factor + 0multiplier +  accum -> s5
s5 + 0factor + 0multiplier + 0accum -> s6

# tmp holds the next factorial, keep it (non-deterministic)
s6 +  tmp -> s6 + accum + factorial
# restore counter

# restore counter and increment it
s6 + counter_copy -> s6 + counter
s6 + 0counter_copy + 0tmp -> counter + s7

# compare current factorial and input
s7 +  input +  factorial -> s7
s7 + 0input + 0factorial -> Out_"1"  # if factorial == input: done (success)
s7 + 0input +  factorial -> Out_"0"  # elif factorial > input: done (current factorial exceeds input)
s7 +  input + 0factorial -> s8       # input > factorial: try next factorial

# cleanup from before
s8 +  input -> s8
s8 + 0input -> s9

# restore input and continue
s9 +  input_copy -> s9 + input
s9 + 0input_copy -> s0

Try it online!

159

C, 50 bytes
p,i;f(int n){p=1;for(i=1;p<n;p*=i++);return p==n;}

Special Thanks to Jo King for shortening the program.

Ah, you can also combine the p and i initialisations to remove a byte

Building on @JoKing 44 bytes

Fortran (GFortran), 57 bytes
read*,i
k=1
do j=1,i
k=k*j
if(i==k)l=1
enddo
print*,l
end

Try it online!
On some compilers may result in gibberish on false-y due to uninitialised l. Can be solved with 3 bytes (l=0) or compiler flags (e.g. -finit-integer=0). Strictly 1 is not a truthy in Fortran, but spec specified 1/0 for true/false.

Python 3.8 (pre-release), 47 bytes
lambda n,t=1:n in[t:=t*i for i in range(1,n+1)]

Try it online! This is not a Python winner, but it does showcase the walrus operator := in a scenario that isn't the typical look at me I'm golfing this and writing really obfuscated Python code :)

-2 bytes: lambda n,t=1:n in[t:=t*-~i for i in range(n)]

Add++, 10 bytes
L,R€R€b*Ae

Try it online!
How it works
L,		; Define the main function that takes one argument, x
		; Example: x = 24		STACK = [24]
	R	; Range				STACK = [[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24]]
	€R	; Range for each		STACK = [[[1] [1 2] [1 2 3] ... [1 2 3 ... 22 23 24]]
	€b*Bh	; Product for each		STACK = [[1 2 6 ... 620448401733239439360000]]
	Ae	; Is x in the array?		Returns 1

Factor, 56 bytes
[| x | 1 1 [ dup x < ] [ [ 1 + dup ] dip * ] while x = ]

Try it online!
There may be a shorter solution using division, since it won't involve a separate accumulator and won't require | x |, but I can't find it yet.
Using /, 59 bytes
[ 1 swap [ dup 1 > ] [ [ 1 + dup ] dip swap / ] while 1 = ]

Try it online!

dip and while are good in production, but they're often losers in code golf. And you can trash the stack and stdout as long as the result is at the top of the stack. I could shorten the * solution to 38 bytes.

The best I could find for / one is 40 bytes. Also locals is visible by default, so you don't need it in the header.

@Bubbler Thanks, those are amazing! They're pretty different from mine, though, so do you want to post your own answer?

Python 2, 35 bytes
f=lambda n,d=1:n<2or n%d<f(n/d,d+1)
Attempt This Online!
-2 bytes thanks to @dingledooper

Because f always returns a boolean, could you just take out the 1> check entirely?

@dingledooper Ah, I thought that would cause infinite recursion, but I was wrong. Thanks!

PHP4 (39 chars)
Given $argv[1] as a command line argument, the script will answer to stdout and silence the notice.
for($n=$argv[1];1<@$n/=++$_;);echo~~$n;

C (std=c99, 44 chars)
The function f will answer up to 18!.
i;f(double n){for(i=1;n>1;n/=++i);return n;}

Edit : saved 2 chars by properly declaring the integer i, thanks to @ceilingcat.

You'd have to add the #include<stdlib.h> to your score if you want to use errno. However, it's actually shorter to declare and use a new variable: https://ato.pxeger.com/run?1=NY5BCsIwFET3PcVQEH6IYupKSHMQQRBNG_mgPxJaN6UncdNND-VtjFhXMwxvmHnN_nT1fprmvgub_duwDdTE_nJrIWoIMRE7Y6uaZOu0ZmWVTW3XJ4E4V9lx6R1YOtzPLPSM3CgMBZDLoG_OcKhslho7Y7LR-kcAHECBWCk8UkYDlavmKOUaeSkDY7EM_A9-AA

@pxeger thank you, i updated the code by declaring a new i variable.

Perl 6, 17 bytes
{$_∈[\*] 1..$_}

Checks whether $_, the argument, is a member of the triangular multiplication reduction (1, 1*2, ..., 1*2*...*$_).
This does a LOT of unnecessary math for larger inputs, but hey, it's short!

JavaScript (ES6), 60 58 bytes
a=>[...Array(a).keys()].some(b=>(f=c=>c?c*f(c-1):1)(b)==a)

CJam, 9 bytes
q~_,:m!e=

Try it online!
This outputs 1 if the input is a factorial, 0 otherwise.
Explanation:
q~           Read the input
  _,         Create array [0,...,Input-1]
    :m!      Factorial of each element of the array
       e=    Check if any element is equal to input

this outputs 0 for 2, try adding ) to increase values. This solution used the exact same logic (was basically identical to yours so I won't post it).

Clojure, 39 bytes
#(=((set(reductions *'(range 1 %)))%)%)

Calculating factorials up-to n seems to be the best way to go. *' supports arbitrary precision, but the runtime and memory usage of this implementation are quite bad for larger inputs. Returns true or false.
If truthy value was allowed to vary (returns the input number or nil) this would be 35 bytes:
#((set(reductions *'(range 1 %)))%)

For small input arguments you could use * instead of *'.

J, 9 bytes
e.!@i.@>:

Try it online!

0=1|!^:_1 should be much faster, and can handle huge numbers.

@Adám wow, I didn't think in terms of inverse per se.

And 0=1|!inv even saves you a byte...

Pyth, 5 bytes
/.!MS

online interpreter link

I was about to post...

@LeakyNun Yeah I felt it. But you posted the Jelly answer I had made...

Python 2 - 48  44 bytes
Thanks, @JonathanAllan, saved 4 bytes
Of course, not as short as the other answer, but doing stuff the old-fashion way:
n,x=input(),1.
while n>1:x+=1;n/=x
print n<1

Try It Online!

C#, 99 bytes
a=>{for(int i=0;i<22;i++){var b=1;for(int j=2;j<i;j++){b*=j;}if(a==b){return true;}}return false;};

It checks, if the input is one of the first 22 factorials, if yes it returns true, otherwise false.

C#, 69 62 60 Bytes
n=>{int l=1,i=1,r=0;for(;i<13;i++)r=(l*=i)==n?1:r;return r;}

With line breaks:
n=> {
        int l = 1, i = 1, r = 0;
        for (; i < 13; i++)
            r = (l *= i) == n
                ? 1
                : r;
        return r;
    }

Or as a whole method (79 71 69 Bytes):
int F(int n){int l=1,i=1,r=0;for(;i<13;i++)r=(l*=i)==n?1:r;return r;}

With line breaks:
int F(int n)
{
    int l = 1, i = 1, r = 0;
    for (; i < 13; i++)
        r = (l *= i) == n
            ? 1
            : r;
    return r;
}

Saved 2 Bytes thanks to Arjun

Can save three bytes: true -> 1>0, false -> 1<0.

@ProgramFOX I got an even better idea - but thank you.

Ah, yeah, that's better :)

How about n=>int l=1,i=1,r=0;for(;i<13;i++)if((l*=i)==n)r=1;return r;}

I don't know C# but can't you use the Ternary operator? r=(l*=i)==n?1:0 instead of if

@Arjun this won't work, as it will overwrite the 1 that may be saved in it.

r=(l*=i)==n?1:r

Now, you, too, are ahead of my JavaScript answer, which will always be stuck on 0 score. :-\

C, 57 bytes
More of a novelty solution more than anything else, just to have some fun with recursion. An iterative solution will most likely be shorter.
g(d,n){n<2?putchar(n+47):g(d+1,n/d*!(n%d));}f(n){g(1,n);}

Actually, 5 bytes
;R♂!c

Try it online!
-2 bytes from Erik the Outgolfer's suggestion on a different answer
Explanation:
;R♂!c
;        duplicate input
 R       range(1, input+1)
  ♂!     factorial of each number in range
    c    does the list contain the input?

Ruby, 39 bytes
->a{(1..a).any?{|e|Math.gamma(e+1)==a}}

Pari/GP, 23 bytes
n->#[x|x<-[1..n],x!==n]

Try it online!

TI-Basic, 12 bytes
sum(Ans=seq(X!,X,1,Ans

This creates a list of all factorials up to the input's factorial, compares each one to the input, and returns the sum of all of the comparisons, which will be 1 if one of the factorials is equal to the input, or 0 if none are. This sum is implicitly returned as it is on the last line of the program.
Call with 53:prgmNAME. Overflows on inputs over 69; to avoid this, use sum(Ans=seq(X!,X,1,1+sqrt(Ans for 15 bytes

Japt, 9 bytes
This is my first Japt answer (and first Esolang answer)!
Uõl d_==U

An optimal solution already exists but that's not a reason for not posting this answer!
Try it online!
Thanks to @ETHproductions and @Shaggy for helping me out in the Japt Chatroom when I was stuck! And special thanks to @ETHproductions for making this language! It feels so good to code in Japt!

Welcome to Japt :) You can save a couple of bytes on this by dropping the first U (it's implicit in this instance) and by using the ¥ shortcut for == (or the ¶ shortcut for ===).

Tcl, 69 bytes
proc F n {incr p
while \$p<$n {set p [expr $p*[incr i]]}
expr $p==$n}

Try it online!

Now as a function it renders 2 bytes less!

Retina, 31 bytes
^
_
+a`(_+) (\1)+
_$1 $#2*
 _$

Try it online!

Takes as input a unary number with _ as tally mark

Forth (gforth), 58 bytes
Surprisingly, the shortest method I could find to do this was iterating the factorial numbers and comparing them to the input.
: f >r 1 1 begin 1+ tuck 1- * tuck r@ >= until r> nip = ;

Try it online!
Explanation
>r              \ place the input on the return stack (saves a lot of stack operations)
1 1             \ place the current factorial-value and the index on the stack
begin           \ start an indefinite loop
   1+ tuck 1-   \ increment the index, save a copy, and then decrement again
   * tuck       \ multiply the factorial and the index and save a copy
   r@           \ copy the input from the return stack
   0>=          \ check if it's greater than or equal to the factorial-value
until           \ end the indefinite loop
r> nip          \ move the input back to the normal stack and delete the index
=               \ compare the input and the final factorial value

CJam, 10 bytes
q~_),:m!&,

Try it online!
Uses similar logic as @FrodCube, but instead calculates set intersection and gets the length of the input. If the last , is dropped, you still get truthy/falsy values, but they are not consistent.

Japt, 4 bytes
õÊøU

Try it online!

Zephyr, 86 bytes
input n as Integer
set i to 1
set f to 1
while f<n
inc i
set f to f*i
repeat
print f=n

Try it online!
f successively takes the value of every factorial from 1 on up, until it is no longer less than the input number n. If f is now equal to n, then n is a factorial and we output true; otherwise, n is not a factorial and we output false.

F#, 79 bytes
let rec f x=if x<2 then 1 else f(x-1)*x
let i n=Seq.map f{0..n}|>Seq.contains n

Try it online!
Maps each number from 0 to n inclusive to its factorial value (through the recursive function f), and checks to see if any of the mapped numbers are n.

Can be refactored with a fold and a lambda to save 16 bytes: fun a->Seq.map(fun b->Seq.fold(*)1[2..b]){0..a}|>Seq.contains a

CJam, 15 bytes
q~_,{)m!}%#-1=!

probably not the shortest answer but it's my first attempt with CJam
Explanation:
    q~_        Get the input and make a copy on the stack
    ,{)m!}%    Factorial all numbers from 1 to input
    #          see if input is in array
    -1=!       if input isn't in array return false otherwise return true

Common Lisp, 56 bytes
(lambda(i)(do((c 0)(j 1(*(incf c)j)))((<= i j)(= j i))))

Try it online

Brain-Flak, 154 bytes
(<>((()))<>){{}(({}))<>({}<>)(({<({}[()])><>({})<>}{})<><({}())>)<>([([{}]{}[(())])](<>)){({}())<>}{}{((<{}>))<>{}}{}<>{}}({}{}<>[{}]<>)((){[()](<{}>)}{})

Try it online!

Tidy, 18 bytes
{x:x in(!)on[1,x]}

Try it online!
Simply tests if x is in the list generated by taking the factorial of each element in [1, x].

GolfScript, 17 bytes
~.),{,1\{)*}/}%?)

Try it online!
Explanation
~                  # Evaluate the input
 .                 # Duplicate the value
  )                # Increment the value
   ,               # Generate range from 1 to input
    {        }%    # Map every item
     ,             # Generate a to-0 range
      1\           # Make the initial product 1
        {  }/      # Foreach over the product:
         )*        # Multiply by the value incremented by 1
               ?)  # Index, and then logicize it

Burlesque, 13 bytes
riJro?!jFi0>=

Try it online!
If you accept -1 as falsey (technically isn't in burlesque) and >0 as truthy can save 3 bytes.
riJ # Read as int and duplicate on stack
ro  # Range from [1,N]
?!  # Factorial each
jFi # Find the index of the element == N
0>= # Found index

ink, 52 bytes
=t(n)
~temp f=1
-(l){n<f:{n==1}->->}
~n=n/f
~f++
->l

Try it online!
Assumes the input is a floating point number. If the number is integer-type, the division on line 4 truncates the quotient, which can cause false positives.
Prints its output (1 or 0) directly to stdout. Because ink.
Ungolfed
== check_if_factorial(input) ==
~ temp iterator = 1
- (loop)
{
    - iterator < input:
        {n == 1 : 1 | 0}
        ->->
}
~ input = input / iterator
~ iterator++
-> loop

2Col, 5 bytes [non-competing]
F!
$^

Try it in 2CollIDE
Basically the same as the Jelly answers. Link leads to the current 2Col interpreter in TIO, with the above code already inserted. 3rd argument is input.
2Col is a language where each line is a 2 character expression of some form. It's what I like to call an "Accumulator-based" language. It works like Stack-based languages, except the "stack" can only contain a single item.
Explanation:
      Implicit input to Cell
F!    Return [1!, 2!, ... n!]
$^    Return whether above return value contains Cell value
      Implicit: Print final line's return value

Axiom, 67 bytes
f(x:NNI):Boolean==(i:=2;r:=1;repeat(r>=x=>break;r:=r*i;i:=i+1);r=x)

some test
(12) -> [[i,f(i)] for i in [0,1,2,3,6,24,25,120,720]]
   (12)
   [[0,false], [1,true], [2,true], [3,false], [6,true], [24,true], [25,false],
    [120,true], [720,true]]
                                                      Type: List List Any

Tcl, 71 bytes
incr p
while \$p<$argv {set p [expr $p*[incr i]]}
puts [expr $p==$argv]

Try it online!

Note: $argv is the variable that carries the argument from console; I had just overridden it to test all test cases at once!

Python 3, 92 bytes
f=lambda n,i='1':n<2or(eval(i)==n if eval(i)>=n else f(n,i+'*%d'%(int(i.split('*')[-1])+1)))

Try it online!
This is the first thing I thought of seeing this challenge, but it didn't turn out as well as I had it in my head, easily beaten by other solutions.
Thanks to lambda for noticing a bug in my submission.

Is there a point to using strings and then evaling it instead of just using a separate variable to keep track of the number? e.g. 46 bytes

JavaScript, 124 bytes
I am nub so here it is:
a=(i)=>{r=1;n=0;while(n>=0){n++;r=r*n;if(i==r){console.log(i,"truthy:",n+"!");break;}else{console.log(i,"falsey:",n+"!");}}}

This link may or may not work. If it does, click run and then type "a(24)" or "a(120)" etc. If you pass-in a non-factorial int, it will run infinitely... so don't do that.

Output is allowed as return values, which could save you a lot of bytes.

Excel, 24 bytes
=OR(A1=FACT(ROW(1:170)))

Vyxal 3.0.0beta.1, 4 bytes
0R!C

Try it online! (link is to literate version)
Explained
0 range ## Range [input, 0]
fact    ## Factorial of each
count   ## Count of input in ^

Thunno D, \$ 4 \log_{256}(96) \approx \$ 3.29 bytes
RFsc

Attempt This Online!
Outputs \$0\$ (falsy) or \$1\$ (truthy).
Explanation
RFsc  # Implicit input
R     # Push range(0, input)
 F    # Factorial of each
  sc  # Input is in this list?
      # Implicit output

all_licenses: 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/


text:
Trim a String without Builtins
Given text, remove leading and trailing whitespace (spaces, tabs, and newlines).
Alternate title: Implement your own string trimming.
Input
ASCII text (printable + spaces, tabs (\t), and newlines (\n)), in whatever format you would like. Carriage returns (\r) are outside of the scope of the input.
Output
The same text in the same format, but with (only) trailing and leading spaces, tabs, and newlines removed.
*Note: If your language naturally outputs a trailing space/newline, please note that in your answer.
Test Cases
This test case ensures that you can handle \s and the like. Please note whitespace in it.
Input
 \s test \t\n

Output
\s test \t\n

For the following test cases (but not the above), \s is space, \t is tab, \n is newline. => splits input and output.
\s\t\n\s => (empty string)

\stest\s => test

\nt\n\st\t => t\n\st

_ => _

\s\s\n\s1\s+\s1\n => 1\s+\s1

||_\s => ||_

No builitins allowed that trim either specific characters or given characters. Builtins that remove arbitrary characters from the beginning/end of a string, or that remove given characters from any position in a string (by default) are allowed.

It's not exactly clear what you mean by no built-ins. Is regex allowed?

Maybe you mean that a trimming function removes a substring from both sides of a string?

@StephenS Yeah that's what I mean.

How about trimming by an integer amount (rather than "remove occurrence of this character"), dequeuing (removing the first item), popping (removing the last item), rotating, splitting?

Why would dequeue not be allowed? How is s[1:] trimming?

@Dennis OK, clarifying this for the last time, deleting all my comments.

I'm voting to close this as unclear because I do not feel that the questions of what is considered a builtin has been completely or reasonably addressed.

Jelly, 8 bytes
>⁶TṬo\Tị

Try it online!

Baby, vanilla baby ;)

Character comparisons work?!

@JonathanAllan Why would they not? Integers and character have the same depth.

I just seem to recall them not working.

@JonathanAllan You probably recall trying to compare strings. That won't work since > vectorizes.

Retina, 10 bytes
^\s+|\s+$

Try it online!
Trailing newline is added automatically and is unavoidable.

Retina can do better. I'm really tempted to post it as a separate answer though.

@Neil go ahead.

Never mind, found a bug in my answer.

might be shorter to use matching with something like: (\S.+?)\s+

Carrot, 21 bytes
#^//\S([\s\S]*\S)?/gS

Try it online!
Explanation
Carrot has several global variables, one for each type: string, float and array. The program starts in string-mode, where all the operators will affect the global string variable. And I call these variables the "stack".
#^                     Set the stack-string to the value of all of the input
/                      Get matches of this regex:
 /\S([\s\S]*\S)?/g
                       And set the stack-array to the array containing these matches
                       There will only ever be one or zero matches
S                      Convert to string-mode by joining the elements of the array

The S operator is supposed to take a string or number as an argument to join the array on, but apparently it is not needed in this case (I don't understand why).

JS (ES6), 27 bytes
i=>i.replace(/^\s+|\s+$/g,"")

Jelly, 11 8 bytes
-2 bytes thanks to Dennis (use direct character conversion, similar to his answer O>32 -> >⁶
-1 byte thanks to Dennis (removing a redundant quick)
>⁶TṂr$Ṁị

Try it online!
Steering clear of anything that could be considered "trimming".
How?
>⁶TṂr$Ṁị - Main link: list of characters (a.k.a. string)  e.g. "  t xt  "
 ⁶       - literal space character
>        - greater than (vectorises)                           [0,0,1,0,1,1,0,0]
  T      - truthy indexes                                      [    3,  5,6    ]
     $   - last two links as a monad
   Ṃ     -   minimum                                                3
    r    -   inclusive range                                   [[3],[3,4,5],[3,4,5,6]]
      Ṁ  - maximum                                             [3,4,5,6]
       ị - index into the input                                 "t xt"

>⁶TṂr$Ṁị works too.

C (gcc) & preprocessor, 152 149 bytes
#define f(x)(x==32|x==9|x==10)
char*t(char*o){int i=strlen(o);for(;--i>0;){if(!f(o[i]))break;o[i]=0;};while(1){if(f(*o))o=o+1;else break;}return o;}

-3 bytes: Ironically, I forgot to remove my spaces.
A function that takes in a char* (pointer to the first character of the string (how C implements strings)), and returns a pointer to the first non-space character in the string, and also replaces all trailing spaces with null bytes, C's string terminator.
Ungolfed:
#define isspace(x) (x==32|x==9|x==10)
// save bytes by not using this whole thing each time
// (32 is ' ', 9 is '\t', 10 is '\n')
char *trim(char *original) {
    int i=strlen(original);
    for(;--i>0;){                   // start at the end of the string, work backwards
        if(!isspace(original[i]))
            break;              // if the character not is a space character, stop working backwards
        original[i]=0;          // else: replace the character with a null byte, C's string terminator
    }
    while(1){
        if(isspace(original[0]))// shift the pointer until the first char is not a space
            original = original + 1;
        else break;
    }
    return original;            // return the modified pointer
}

PHP, 40 Bytes
Regex Version

<?=preg_replace("#^\s+|\s+$#","",$argn);

Try it online!
PHP, 77 Bytes
The Regex version was so boring so I would try it without a Regex

<?=substr($a=$argn,strspn($a,$c="\t\n "),-strspn(strrev($a),$c)?:strlen($a));

Try it online!

Python 2, 44 bytes
lambda s:re.sub(r'^\s*|\s*$','',s)
import re

Try it online!
Non-regex: 62 bytes
Takes input as list of characters. Outputs by reference.
def f(s):exec'while s[%s].isspace():del s[%s]\n'*2%(0,0,-1,-1)

Japt, 9 bytes
e"^%s|%s$

Try it online (-Q flag used for visualisation only)

C#, 60 bytes
s=>System.Text.RegularExpressions.Replace(s,"^\s+|\s+$","");

If I could use built-ins this is only 12 bytes:
s=>s.Trim();

source: Stack Exchange

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

sort: votes


text:
What season is it?
Task
When running the program must show the season according to the host computer's current time.
Rules

The output must be either: Spring, Winter, Summer or Autumn.
The capitalization does not matter.
The output must not contain anything else the the season names stated above.
A season is 3 months and january is in this case the start of spring. (Northern hemisphere)

Testcase
(program ran in January)
Output:
Spring

(program ran in April)
Output:
Summer

Scoring
This is code-golf. Shortest answer in bytes wins.

Can we return one of 0, 1, 2, 3 instead of Spring, Winter, Summer, Autumn?

What ranges of dates are in each season?

And in mine, spring starts from march

What if I live in the Southern Hemisphere?

@IanMiller do you have other seasons there? for this challenge you need to output the season as in january is the start of spring december is the end of winter etc

And can someone tell my what is unclear as i would like to clear up any confusing things. The current anwsers all followed the challenge

@Ayoungcoder can you provide specific date ranges for "3 months"? Should we just use the solstices/equinoxes? And january is definitely winter...

Of course the Southern Hemisphere has different seasons. For example January would be the middle of summer. I therefore thought that January would be the middle of winter in the Northern Hemisphere.

05AB1E, 25 16 bytes
“Ž¹Ž€È±–„“#žf3÷è

Explanation:
“Ž¹Ž€È±–„“        Push the string 'spring summer autumn winter'
          #       Split on spaces
           žf     Push month
             3÷   Integer divided by 3
               è  Index

Try it online!

Jelly, 40 bytes
“¡ɗNʂ:ḲO¶Z{ṅ{Ḳ®⁵⁹¢»ŒV’:3ị“ȷ14ċ⁵¶<b_þṭ»Ḳ¤

Jelly has no native date functionality, yet this program prints Spring in January, February and March; Summer in April, May and June; Autumn in July, August, and September; and Winter in October, November and December.
Try it online!
How?
“¡ɗNʂ:ḲO¶Z{ṅ{Ḳ®⁵⁹¢»ŒV’:3ị“ȷ14ċ⁵¶<b_þṭ»Ḳ¤ - Main link: no arguments
“¡ɗNʂ:ḲO¶Z{ṅ{Ḳ®⁵⁹¢»                      - compressed string: " time.gmtime().tm_mon"
                   ŒV                    - evaluate Python code - gets the month, January=1 ... December=12 (the time module has been imported in the interpreter for the time formatting atom ŒT)
                     ’                   - decrement
                     :3                  - integer divide by three
                                       ¤ - nilad followed by link(s) as a nilad:
                         “ȷ14ċ⁵¶<b_þṭ»   - compressed string "Summer Autumn Winter Spring"
                                      Ḳ  - split on spaces
                        ị                - index into (1-based)
                                         - implicit print

That is stupidly clever. Take a +1.

Japt, 32 30 27 bytes
`spÎAdä>H©umØC`qd gKg z3

Try it online

Explanation
A compressed string of lowercase, separated season names delimited with d is decompressed by enclosing it in backticks. qd splits the string into an array on ds. The g method gets the element at the index of the current month (Kg) floor divided by 3 (z3).


text:
Bake me a cake!
This is a cake:
_========_
|        |
+________+
|        |
+________+
|        |
+________+

It is 8 wide, 3 tall, and 1 deep.
You must write a program that makes a cake from 3 inputs. The first input controls how many underscores there are in the middle and =s on the top. Here's the first cake with a width of 10 instead of 8:
_==========_
|          |
+__________+
|          |
+__________+
|          |
+__________+

The second input controls how tall the cake is. Here's the second cake with a height of 4 instead of 3:
_==========_
|          |
+__________+
|          |
+__________+
|          |
+__________+
|          |
+__________+

Note the repetition of the layers.
The third input controls how deep it is. That just how many |      |s to include on the top. Here's the third cake with a depth of 2 instead of 1:
_==========_
|          |
|          |
+__________+
|          |
+__________+
|          |
+__________+
|          |
+__________+

You can print trailing whitespace. Test cases:
Input: 3, 3, 3
Output:
_===_
|   |
|   |
|   |
+___+
|   |
+___+
|   |
+___+

(I hope I never get this cake)
Input: 3, 2, 1
Output:
_===_
|   |
+___+
|   |
+___+

Input: 5, 5, 5
Output:
_=====_
|     |
|     |
|     |
|     |
|     |
+_____+
|     |
+_____+
|     |
+_____+
|     |
+_____+
|     |
+_____+

Will inputs always be positive integers?

@NickClifford yes.

Are trailing newlines allowed?

Related

@Shaggy i'd assume so, it is yes by default on Meta.

@Shaggy "You can print trailing whitespace."

Thanks, @programmer5000; somehow I managed to read it as trailing spaces were allowed rathee than trailing whitespace in general.

V, 25, 20 bytes
2é_Àé=ÙÒ|èÙÒ+È_ÀäkÀÄ

Try it online!
Hexdump:
00000000: 32e9 5fc0 e93d d9d2 7ce8 d9d2 2bc8 5fc0  2._..=..|...+._.
00000010: e46b c0c4                                .k..

Thanks to @nmjmcman101 for saving three bytes, and reminding me of an old operator that saved another two bytes.
Explanation:
a, b, and c are the three arguments.
2é_                   " Insert two '_' characters
   Àé=                " Insert 'a' '=' characters between them
      Ù               " Duplicate this line
       Ò|             " Replace this whole line with '|'s
         è            " *Hollow* this line (replace all the middle characters with spaces)
          Ù           " Duplicate this line
           Ò+         " Replace this whole line with '+'s
             È_       " *Hollow* this line again, but use '_' instead of spaces
               Àäk    " Make 'b' copies of this line and the line above it
                  ÀÄ  " Make 'c' copies of this line

I think you can replace Ò r|$. with Ò|è for some bytes.Try it online!

@nmjcman101 Oh man, I completely forgot that è even existed. I had to rack my brain to remember what it does. But that's really clever! In fact, using the uppercase variant, È<char> can probably save some more bytes in a few other places too. Thanks for reminding me! :)

Charcoal, 34 26 bytes
Ｎγ←×γ_↑+↑Ｎ_×γ=‖ＢＯγＦ⁻Ｎ¹Ｃ⁰±²

Try it online! Link is to verbose version of code. Takes parameters in the order width, depth, height. Explanation:
Ｎγ          Input the width.
←×γ_        Print a set of _s that go at the bottom of each layer.
↑+          Print one of the +s that go on the left.
↑Ｎ          Input the depth and print that many left |s.
_           Print the top left _.
×γ=         Print the =s along the top.
‖ＢＯγ        Copy the left column to the right.
Ｆ           Repeat:
 ⁻ ¹         One time fewer than:
  Ｎ           Input of the height:
    Ｃ⁰±²        Copy the whole cake up 2 characters.

05AB1E, 33 31 bytes
'_'=¹×«Ć,'|¹úRĆ³G=}²F='+'_¹×«Ć,

Try it online!
Explanation
'_'=¹×«Ć,'|¹úRĆ³G=}²F='+'_¹×«Ć,   Full program
'_                                Push literal '_'
  '=¹×                            Push '=' w times
      «Ć,                         Concat, enclose and print
         '|                       Push literal '|'
           ¹ú                     Pad with w spaces in front
             RĆ                   Reverse and ecnlose
               ³G }               d - 1 times do:
                 =                Print without consuming
                   ²F             h times do:
                     =            Print without consuming
                      '+          Push literal '+'
                        '_¹×      Push '_' w times
                            «Ć,   Concat, enclose and print

PHP>=7.1, 104 Bytes
for([,$w,$h,$t]=$argv;$i<2*$h+$t;)echo str_pad($e="_|+"[$b=$i++<$t?$i>1:1+$_++%2],$w+1,"= _"[$b])."$e
";

Online Version

Not bad. Found 3 byte: for([,$w,$h,$t]=$argv;$i<2*$h+$t;)echo str_pad($e="_|+"[$b=$i++<$t?$i>1:2-($i-$t&1)],$w+1,"= _"[$b])."$e\n";

And another 3 byte: $b=$i++<$t?$i>1:1+$_++%2.

@Christoph Nice idea Thank You

Mathematica, 167 bytes
c=Column;r=Row;t=Table;f=Flatten;c[c/@{r/@f[{{{"_",r@t["=",#],"_"}},t[{"|",r@t[" ",#],"|"},#3-1]},1],c/@f[{t[{r@{"|",r@t[" ",#],"|"},r@{"+",r@t["_",#],"+"}},#2]},1]}]&

Jelly, 30 29 bytes
-1 byte switching from an addition to an XOR to translate between outer and inner columns, allowing for a 5 character lookup rather than having two _ entries.
ṬṚ;⁹RḤṬḤ¤Wµ^9ẋ⁵;@;µZị“_+= |”Y

Full program taking three program arguments of depth, height, width and printing the cake.
Try it online!
How?
ṬṚ;⁹RḤṬḤ¤Wµ^9ẋ⁵;@;µZị“_+= |”Y - Main link: depth, height (width is a program argument)
Ṭ                             - untruth   [0,0,0,...1] such that the length is the depth
 Ṛ                            - reverse   [1,0,0,...0]
        ¤                     - nilad followed by link(s) as a nilad:
   ⁹                          -   link's right argument, height
    R                         -   range   [1,2,3,...,height]
     Ḥ                        -   double  [2,4,6,...,2*height]
      Ṭ                       -   untruth [0,1,0,1,0,1,...,0,1] (length double height)
       Ḥ                      -   double  [0,2,0,2,0,2,...,0,2]
  ;                           - concatenate  [1,0,0,...,0,0,2,0,2,0,2,...,0,2]
                              -     ...this is the form of a column of cake!
         W                    - wrap in a list
          µ                   - monadic chain separation, call that c
           ^9                 - bitwise XOR c with 9 [8,9,9,...,9,9,11,9,11,9,11,...,9,11]
              ⁵               - program's 3rd argument, width
             ẋ                - repeat the augmented c width times
               ;@             - concatenate with a copy of c
                 ;            - concatenate a copy of c
                  µ           - monadic chain separation call that sideways cake
                   Z          - transpose the sideways cake to put it the right way up
                     “_+= |”  - literal ['_','+','=',' ','|'] (cake decoration)
                    ị         - index into (1 based and modular, so 8,9, and 11 are, mod 5,
                                            3, 4, and 1 yielding '=', ' ', and '_')
                            Y - join with new lines
                              - implicit print

Ruby, 62 bytes
->w,h,d{l="|#{' '*w}|
";"_#{?=*w}_
"+l*~-d+(l+"+#{?_*w}+
")*h}

Try it online!

Haskell, 87 bytes
f w t d=["_=| +_\n"!!j|i<-0:([2..d]>>[2])++([1..t]>>[2,4]),j<-i:([1..w]>>[i+1])++[i,6]]

Nice job leaving most non-golfing languages way behind. An infix declaration (w#t)d= ... saves a byte.

Japt, 51 47 bytes
"_{ç'=}_"+WçA="
|{ç}|" +(B="
+{ç'_}+" +(´V çA+B

Try it online!
Input is taken in the order width, height, depth.

Windows Batch, 211 180 163 bytes
Golfed a total of 48 bytes thanks to @Neil!
@for /l %%p in (1,1,%1)do @call set w= %%w%%
@echo _%w: ==%_
@for /l %%p in (2,1,%3)do @echo ^|%w%^|
@for /l %%p in (1,1,%2)do @echo ^|%w%^|&echo +%w: =_%+
@set w=

Using @ on each line and after do is slightly shorter than @echo off. 2. @call set w=%%w%%_ avoids setlocal enabledelayedexpansion. 3. Use @for /l %%p in (2,1,%2). 4. IMHO you should add @set w= so that the code works more than once.

I am confused by the last part, if I don't add @set w=, will the code not work for more then once?

Your @for /l %%p in (1,1,%1)do seems to have gone missing. 2. Your cake seems to be the wrong height, at least it doesn't seem to match the test case when I try it. 3. If you run the script twice in the same command session then the cake just gets wider and wider.

@Neil It's all fixed :)

Great! Just a few last things I noticed: 1. You don't need the @ after the &. 2 If you change the second loop to (2,1,%3) and the third loop to (1,1,%2) then I think you can delete the echo +%w%+ line. 3. If I've counted correctly, then I think you should fill w with spaces instead of _s, as that will result in fewer substitutions. (I would use @call set w= %%w%% as otherwise the space is hard to spot!)

Java 7, 169 164 158 bytes
String f(int...a){String s="_",t="|",u="+";for(;a[0]-->0;s+="=",t+=" ")u+="_";s=s+"_";t="\n"+t+"|";u=t+"\n"+u+"+";for(;a[2]-->1;)s+=t;for(;a[1]-->0;)s+=u;return s;}

Try it online!
Ungolfed:
String f(int...a)                    // saves two bytes over int a, int b, int c
{
    String s="_", t="|", u="+";      // set up the start of each row

    for(; a[0]-->0; s+="=", t+=" ")  // Uses the goes-to operator to fill the row
        u+="_";

    s += "_\n";                      // adds the end of each row
    t += "|\n";
    u = t + u + "+\n";               // and combining t into u

    for(; a[2]-->1; )                // add the top of the cake
        s += t;

    for(; a[1]-->0; )                // add the rest of the cake
        s += u;

    return s;
}

You can save 1 byte by putting u=t+u+"+\n" inside the for-loop: for(u=t+u+"+\n;a[2]-->1;)s+=t;`. But nice answer, +1 from me.

Python 2, 124 122 120 105 92 bytes
w,t,d=input()
a="\n|"+w*" "+"|"
print"_"+w*"="+"_"+(d-1)*a+t*(a+"\n+"+w*"_"+"+")

-15 bytes by using STDIN instead of program arguments
-13 bytes by switching to Python 2 (for input()ing integers and print statement)
-12 bytes from Caird Coinheringaahing
Try it online!
Python 3, 124 122 120 105 bytes
w,t,d=[int(input())for n in(1,2,3)]
a="\n|"+w*" "+"|"
print("_"+w*"="+"_"+(d-1)*a+t*(a+"\n+"+w*"_"+"+"))
Try it online!
If a full program is not required:
Python 3, 87 84 bytes
lambda w,t,d:"_"+w*"="+"_"+(d-1)*("\n|"+w*" "+"|")+t*("\n|"+w*" "+"|\n+"+w*"_"+"+")
Try it online!

80 bytes

@cairdcoinheringaahing 78 bytes.

dc, 108 bytes
?sdstsw95P61sc[lwsf[lcPlf1-dsf0<a]dsax]dsbx[_]p[[124P32sclbx[|]pld1-dsd0<j]dsjx43P95sclbx[+]plt1-dst0<h]dshx

Try it online!

Röda, 65 bytes
a,b,c{d=" "*a;[`_${"="*a}_
`,`|$d|
`*(c-1),`|$d|
+${"_"*a}+
`*b]}

Try it online!

SOGL V0.12, 25 bytes
e =*¼_Oe↕¼|.⌡Qe╔*¼+.H«{Q;

Try it Here!
Expects the input as width, depth, then height.

Is it allowed to re-order inputs?  They seem to specified in a prescribed order.

@recursive Usually it's allowed and nowhere does the question force the ordering and the 2nd most voted answer reorders the inputs and probably has been seen by the OP, so I'd assume it's fine.

Javascript (ES6), 161 157 bytes

f=(w,h,d)=>{r=x=>x.repeat(w);_='_';m='+'+r(_)+'+';b='|'+r(' ')+'|';c=[_+r('=')+_];for(i=d-1;i--;)
c.push(b);for(i=h;i--;)
c.push(b+'\n'+m);return c.join`\n`}

console.log(f(8,3,1));

Python 2, 93 bytes
i,j,k=input()
l=["|"+" "*i+"|"]
for x in["_"+"="*i+"_"]+l*(k-1)+(l+["+"+"_"*i+"+"])*j:print x

Try it online!

Perl 5, 85 + 1 (-a) = 86 bytes
say"_".'='x($w=$F[0])."_\n".($l='|'.$"x$w."|\n")x($F[2]-1).("$l+".'_'x$w."+\n")x$F[1]

Try it online!

JavaScript/ES6, 90 bytes
I just wrote a rough solution, and happened to beat the existing JS answer by a whopping 56 bytes. Then I golfed off 11 bytes.
(w,h,d,g=a=>a+a[1][r='repeat'](w)+a[0]+`
`)=>g('_=')+(l=g('| '))[r](d-1)+(l+g('+_'))[r](h)

Here's a demo.

var F = (w,h,d,f=a=>a+a[1][r='repeat'](w)+a[0]+`
`)=>f('_=')+(l=f('| '))[r](d-1)+(l+f('+_'))[r](h);

console.log(F(prompt('width') || 3, prompt('height') || 3, prompt('depth') || 3));
console.log(F.toString().length);

Canvas, 23 bytes
|＊_⁷⇵×+×∔║│Ｐ
=×_ｅＰ⁸╷｛１⁸

Try it here!

Google Sheets, 89
Inputs A1, A2, A3.

A4 - _
A5 - (Discount 1 for ")
="|"&REPT(" ",A1)&"|
"

Final output (Discount 1 for )):
=A4&REPT("=",A1)&"_
"&REPT(A5,A3-1)&REPT(A5&"+"&REPT(A4,A1)&"+
",A2)