• BreadstickNinja@lemmy.world
    link
    fedilink
    English
    arrow-up
    15
    ·
    edit-2
    2 days ago

    Factorial means n! = (n)(n-1)(n-2)… etc. down to 1, where n is a positive integer. It’s used to calculate the different number of configurations of a set of elements, mainly in combinatorics.

    Like if you have four different objects and you want to know how many different configurations you can order them in, you have four choices for the first object, then three for the second, then two for the third, then one for the final slot. So the answer is 4 x 3 x 2 x 1 = 24 = 4!.

      • pyre@lemmy.world
        link
        fedilink
        English
        arrow-up
        7
        ·
        edit-2
        17 hours ago

        the most tangible and direct application is how many different ways you can order x many items.

        eg. how many different ways can you order 3 items?

        let’s say you have these 3 items: 🍏🫐🍒

        the first one can be any one of the three, so you have 3 options. that’s 3 different ways to start your order. let’s write that down:

        3

        now for the second one. whichever one you picked for first position will be unavailable, so you’ll have 2 options this time. this is true for each first pick separately, so you multiply the possible number of first picks by the possible number of second picks:

        3 x 2

        now for the third item, since two of the three are already picked, you only have one left, which means not much to choose. you just multiply the 1:

        3 x 2 x 1

        of course multiplying by 1 doesn’t change anything but as we mentioned there was no option this time, once you pick the second fruit the third is also auto-picked, so the third item doesn’t add to our number.

        so the final answer seems to be:

        3 x 2 x 1 = 6

        is that true? might feel like there should be more ways but let’s test it; can’t be that complicated:

        1. 🍏🫐🍒
        2. 🍏🍒🫐
        3. 🫐🍏🍒
        4. 🫐🍒🍏
        5. 🍒🍏🫐
        6. 🍒🫐🍏

        here you go. you can extrapolate this logic to any number. four items would’ve followed the same sequence starting with 4 and have 1 less option with each pick, so 4 x 3 x 2 x 1. and that’s also 4!

      • Hamartiogonic@sopuli.xyz
        link
        fedilink
        English
        arrow-up
        2
        ·
        1 day ago

        Makes things shorter.

        In the applications mentioned by other people, you run into calculations that would look really messy and confusing. Things like 5•4•3•2•1 can be shorted to just 5! Imagine writing the full version of 123!

      • HMitsuha@sh.itjust.works
        link
        fedilink
        English
        arrow-up
        4
        ·
        1 day ago

        There are lots of applications, so I’ll give you three

        Factorials are used in the Taylor Series to approximate trigonometric (sine, cosine, etc) and the exponential function. This can help speed up calculations.

        In probability and statistics, if you want to find how many different ways a deck of cards can be shuffled, the answer is 52! Because the first card can be any of the 52, the second can be any of the remaining 51, and so on until the last card. Building upon this concept results in ways to model data like the binomial distribution , which is simply “how many successes will i get if i do this trial a certain number of times”. E.g. If I flip a coin 100 times, how many times will it be heads?

        In computer science, the complexity of a program is compared to functions like the factorial, exponential, quadratic, etc. to visualize it’s performance given the size of the input, n. E.g. a program of linear time complexity is denoted as O(n), and as n increases, we expect the time for the program to finish to increase linearly. For a factorial time complexity, O(n!), we expect the time to complete to increase a lot compared to O(n)