Sum and product of an array: Difference between revisions
Content added Content deleted
(Sum and product of an array in Asymptote) |
|||
Line 368: | Line 368: | ||
<pre>Sum = 55 |
<pre>Sum = 55 |
||
Product = 3628800</pre> |
Product = 3628800</pre> |
||
=={{header|Asymptote}}== |
|||
<lang Asymptote>int[] matriz = {1,2,3,4,5}; |
|||
int suma = 0, prod = 1; |
|||
for (int p : matriz) { |
|||
suma += p; |
|||
prod *= p; |
|||
} |
|||
write("Sum = ", suma); |
|||
write("Product = ", prod);</lang> |
|||
{{out}} |
|||
<pre>Sum = 15 |
|||
Product = 120</pre> |
|||
=={{header|AutoHotkey}}== |
=={{header|AutoHotkey}}== |