Description overhauled by V

---

I've invited some kids for my son's birthday, during which I will give to each kid some amount of candies.

Every kid hates receiving less amount of candies than any other kids, and I don't want to have any candies left - giving it to my kid would be bad for his teeth.

However, not every kid invited will come to my birthday party.

What is the minimum amount of candies I have to buy, so that no matter how many kids come to the party in the end, I can still ensure that each kid can receive the same amount of candies, while leaving no candies left?

It's ensured that at least one kid will participate in the party.

Difficulty: introductory

Starter code:

def candies_to_buy(n):
	

Solutions:
from fractions import gcd
from functools import reduce

def candies_to_buy(n):
    return reduce(lambda a,b:a*b//gcd(a,b), range(1,n+1))

def candies_to_buy(n):
    xx = 1
    for i in range(n):
        x = xx
        while xx % (i+1):
            xx += x
    return xx

from functools import reduce
from math import gcd

def lcm(a, b):
    g = gcd(a, b)
    return a * b // g

def candies_to_buy(kids):
    return reduce(lcm, range(1, kids+1))

from itertools import accumulate
from math import gcd

lcm = lambda x,y: x * y // gcd(x, y) if x else y

candies_to_buy = list(accumulate(range(2000), lcm)).__getitem__

from functools import reduce
from math import gcd

def candies_to_buy(kids):
    return reduce(lambda a, b: a * b // gcd(a, b), range(1, kids+1))

from fractions import gcd
from functools import reduce

def lcm(a, b):
    return a * b // gcd(a, b)

def candies_to_buy(amount_of_kids_invited):
    return reduce(lcm, range(1, amount_of_kids_invited + 1))

from math import gcd
from functools import reduce

lcm = lambda x,y: x*y//gcd(x,y)

def candies_to_buy(n):
    return reduce(lcm, (i for i in range(1,(n+1 if n%2 else n)))) if n!=2 else 2

import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)

def candies_to_buy(amount_of_kids_invited):
    f = 1
    for i in range(2, amount_of_kids_invited+1):
        f = lcm(f, i)
    return f

from operator import mul
from functools import reduce
def candies_to_buy(n):
    ret = []
    for i in range(1, n + 1):
        s = i
        for j in ret:
            if s % j == 0:
                s //= j
            if s == 1:
                break
        ret.append(s)
    return  reduce(mul, ret)