## 30秒学会 Python 片段 – lcm

Returns the least common multiple of a list of numbers.

Use `functools.reduce()`, `math.gcd()` and `lcm(x,y) = x * y / gcd(x,y)` over the given list.

## 30秒学会 PHP 片段 – gcd

Calculates the greatest common divisor between two or more numbers.

Use recursion.
Use `array_reduce()` with the `gcd` function to appy to all elements in the `\$numbers` list.
Base case is when `y` equals `0`. In this case, return `x`.
Otherwise, return the gcd of `y` and the remainder of the division `x/y`.

## 30秒学会 JavaScript 片段 – renderElement

Renders the given DOM tree in the specified DOM element.

Destructure the first argument into `type` and `props`, use `type` to determine if the given element is a text element.
Based on the element’s `type`, use either `Document.createTextNode()` or `Document.createElement()` to create the DOM element.
Use `Object.keys(props`, adding attributes to the DOM element and setting event listeners, as necessary.
Use recursion to render `props.children`, if any.
Finally, use `Node.appendChild()` to append the DOM element to the specified `container`.

## 30秒学会 Python 片段 – deep_flatten

Deep flattens a list.

Use recursion.
Use `isinstance()` with `collections.abc.Iterable` to check if an element is iterable.
If it is, apply `deep_flatten()` recursively, otherwise return `[lst]`.

## 30秒学会 Dart 片段 – flatten

Flattens a list.

Use recursion.
Use `Iterable.expand()` to combine elements into a single list, calling `flatten` recursively for any elements that are `List`s.

## 30秒学会 JavaScript 片段 – initializeNDArray

Create a n-dimensional array with given value.

Use recursion.
Use `Array.prototype.map()` to generate rows where each is a new array initialized using `initializeNDArray`.

## 30秒学会 JavaScript 片段 – deepFlatten

Deep flattens an array.

Use recursion.
Use `Array.prototype.concat()` with an empty array (`[]`) and the spread operator (`...`) to flatten an array.
Recursively flatten each element that is an array.

## 30秒学会 JavaScript 片段 – deepMapKeys

Deep maps an object’s keys.

Creates an object with the same values as the provided object and keys generated by running the provided function for each key.
Use `Object.keys(obj)` to iterate over the object’s keys.
Use `Array.prototype.reduce()` to create a new object with the same values and mapped keys using `fn`.

## 30秒学会 C# 片段 – GCD

Calculates the greatest common divisor of the given numbers.

Define a `GCD()` function for two numbers, which uses recursion.
Base case is when `y` equals `0`, which returns `x`.
Otherwise the GCD of `y` and the remainder of the division `x/y` is returned.
Define an overload that accepts multiple numbers or an array and use `IEnumerable.Aggregate()` to apply `GCD()` to them.