Sum multiples of 3 and 5: Difference between revisions

Line 2,055:
TT = 2333333333333333333316666666666666666668.
</pre>
 
=={{header|PureBasic}}==
<lang PureBasic>
EnableExplicit
 
Procedure.q SumMultiples(Limit.q)
If Limit < 0 : Limit = -Limit : EndIf; convert negative numbers to positive
Protected.q i, sum = 0
For i = 3 To Limit - 1
If i % 3 = 0 Or i % 5 = 0
sum + i
EndIf
Next
ProcedureReturn sum
EndProcedure
If OpenConsole()
PrintN("Sum of numbers below 1000 which are multiples of 3 or 5 is : " + SumMultiples(1000))
PrintN("")
PrintN("Press any key to close the console")
Repeat: Delay(10) : Until Inkey() <> ""
CloseConsole()
EndIf
</lang>
 
{{out}}
<pre>
Sum of numbers below 1000 which are multiples of 3 or 5 is : 233168
</pre>
 
=={{header|Python}}==
Three ways of performing the calculation are shown including direct calculation of the value without having to do explicit sums in sum35c()
9,476

edits