2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.

What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?

The next problem is just folding two values from an array and replacing them with their LCM, then run again and again until only one item is left in the collection (and you now have the LCM of all entries).

functionGet-Gcd{param($lhs,$rhs)if($lhs-eq$rhs){return$rhs}if($lhs-gt$rhs){$a,$b=$lhs,$rhs}else{$a,$b=$rhs,$lhs}while($a%$b-ne0){$tmp=$a%$b$a,$b=$b,$tmp}return$b}functionGet-Lcm{param($lhs,$rhs)[long][Math]::Abs($lhs*$rhs)/(Get-Gcd$lhs$rhs)}functionGet-LcmOfGroup{param([int[]]$values)$lhs=$values[0]$rhs=$values[1]$lcm=Get-Lcm$lhs$rhs$values=@($lcm)+$values[2..$values.Length]if($values.Length-eq1){return$lcm}else{Get-LcmOfGroup$values}}functionSolve-Problem5{Get-LcmOfGroup@(1..20)}Write-Host"Elapsed Time (s): "(Measure-Command{Solve-Problem5}).TotalSecondsWrite-Host"Solution: "(Solve-Problem5)ElapsedTime(s):0.0407472Solution:232792560