Sum multiples of 3 and 5: Difference between revisions
Content added Content deleted
m (→{{header|Haskell}}: Tidied) |
|||
Line 2,394: | Line 2,394: | ||
</pre> |
</pre> |
||
=={{header|Mathematica}}== |
=={{header|Mathematica}}/{{header|Wolfram Language}}== |
||
<lang mathematica>sum35[n_] := |
<lang mathematica>sum35[n_] := |
||
Sum[k, {k, 3, n - 1, 3}] + Sum[k, {k, 5, n - 1, 5}] - |
Sum[k, {k, 3, n - 1, 3}] + Sum[k, {k, 5, n - 1, 5}] - |
||
Sum[k, {k, 15, n - 1, 15}] |
Sum[k, {k, 15, n - 1, 15}] |
||
sum35[1000]</lang> |
sum35[1000]</lang> |
||
{{out}} |
{{out}} |
||
Line 2,405: | Line 2,404: | ||
{{out}} |
{{out}} |
||
<pre>233333333333333333333166666666666666666668</pre> |
<pre>233333333333333333333166666666666666666668</pre> |
||
Another alternative is |
Another alternative is |
||
<lang mathematica> Union @@ Range[0, 999, {3, 5}] // Tr </lang> |
<lang mathematica> Union @@ Range[0, 999, {3, 5}] // Tr </lang> |