Sum and product of an array: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 1,185:
product[a]
</syntaxhighlight>
 
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
local fn Sum( mutArr as CFMutableArrayRef ) as float
NSInteger i, count, value = 0
float sum = 0
count = fn ArrayCount( mutArr )
for i = 0 to count -1
value = fn NumberIntegerValue( fn ArrayObjectAtIndex( mutArr, i ) )
sum += value
next
end fn = sum
 
 
local fn Product( mutArr as CFMutableArrayRef ) as float
NSInteger i, count, value = 0
float prod = 0
count = fn ArrayCount( mutArr )
for i = 0 to count -1
value = fn NumberIntegerValue( fn ArrayObjectAtIndex( mutArr, i ) )
prod *= value
next
end fn = prod
</syntaxhighlight>
 
 
=={{header|Fōrmulæ}}==
Line 1,215 ⟶ 1,245:
The Product = 120
</pre>
 
 
=={{header|GAP}}==
Line 1,232 ⟶ 1,263:
Product(v, n -> 1/n);
# 1/40320</syntaxhighlight>
 
 
 
=={{header|GFA Basic}}==
Line 1,252 ⟶ 1,285:
PRINT "Product is ";product%
</syntaxhighlight>
 
 
 
=={{header|Go}}==
717

edits