Sum and product of an array: Difference between revisions

Sum and product of an array in Asymptote
(Sum and product of an array in Asymptote)
Line 368:
<pre>Sum = 55
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}}==
2,130

edits