Averages/Pythagorean means: Difference between revisions

Content added Content deleted
(Added Processing code)
Line 3,417: Line 3,417:


=={{header|Vlang}}==
=={{header|Vlang}}==
Updated for Vlang version 0.2.2
<lang vlang>import (
<lang go>import math
arrays
math
)


fn main() {
fn main() {
Line 3,426: Line 3,424:
mut prod :=1.0
mut prod :=1.0
mut recip_sum := 0.0
mut recip_sum := 0.0
n := 10.0
n := 10
for val in arrays.range<int>(1, n+1) {
for val in 1..(n + 1) {
sum += val
sum += val
prod *= val
prod *= val
recip_sum = recip_sum + (1.0/val)
recip_sum = recip_sum + ( 1.0 / val )
}
}
a := sum / n
a := sum / n
g := math.pow(prod, (1.0/n))
g := math.pow( prod, ( 1.0 / f32(n) ) )
h := n / recip_sum
h := n / recip_sum
result := 'Arithmetic Mean: ${a : 3.2f} \nGeometric Mean: ${g : 3.2f}\nHarmonic Mean: ${h : 3.2f}'
result := 'Arithmetic Mean: ${a:3.2f} \nGeometric Mean: ${g:3.2f}\nHarmonic Mean: ${h:3.2f}'
println(result)
println( result )
x := if a >= g && g >= h {"Yes"} else {"Nope"}
compare := if a >= g && g >= h { "Yes" } else { "Nope" }
println('Is A >= G >= H? $x')
println('Is A >= G >= H? $compare')
}</lang>
}</lang>
{{out}}
{{out}}