Anonymous user
Sum multiples of 3 and 5: Difference between revisions
→{{header|PowerShell}}
Drkameleon (talk | contribs) |
|||
Line 2,541:
=={{header|PowerShell}}==
<lang powershell>
function SumMultiples ( [int]$Base, [int]$Upto )
{
$X = (
$Sum = ( $X * $X
Return $Sum
}
Line 2,556 ⟶ 2,554:
{{out}}
<pre>
233168
</pre>
<lang powershell>
function SumMultiples ( [bigint]$Base, [bigint]$Upto )
{
$X = (
$Sum = ( $X * $X
Return $Sum
}
Line 2,573 ⟶ 2,571:
{{out}}
<pre>
233333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333166666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666668
</pre>
Here is a cmdlet that will provide the sum of unique multiples of any group of numbers below a given limit. I haven't attempted the extra credit here as the math is too complex for me at the moment.
|