Averages/Arithmetic mean: Difference between revisions
Content added Content deleted
Line 1,630: | Line 1,630: | ||
<lang ruby>nums = [3, 1, 4, 1, 5, 9] |
<lang ruby>nums = [3, 1, 4, 1, 5, 9] |
||
nums.empty? ? 0 : nums.inject(:+) / Float(nums.size)</lang> |
nums.empty? ? 0 : nums.inject(:+) / Float(nums.size)</lang> |
||
=={{header|Run BASIC}}== |
|||
<lang runbasic>print "Gimme the number in the array:";input numArray |
|||
dim value(numArray) |
|||
for i = 1 to numArray |
|||
value(i) = i * 1.5 |
|||
next |
|||
for i = 1 to total |
|||
totValue = totValue +value(numArray) |
|||
next |
|||
if totValue <> 0 then mean = totValue/numArray |
|||
print "The mean is: ";mean</lang> |
|||
=={{header|Sather}}== |
=={{header|Sather}}== |