Task: Create a list in the range from -n to n according to the following pattern: -n, n-1, - (n-2), n-3 ... Find the arithmetic mean of the list elements.
F # code:
open System let n = 20 let array = [| for i in 0 .. n -> if i%2=0 then ((ni)* -1) else ni |] printfn "%A" array array |> Array.sum |> printfn "Π‘ΡΠ΅Π΄Π½Π΅Π΅ Π°ΡΠΈΡΠΌΠ΅ΡΠΈΡΠ΅ΡΠΊΠΎΠ΅ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠΎΠ² ΡΠΏΠΈΡΠΊΠ°: %A" let ar = array |> Array.sum |> fun a -> a / 20 printfn "sum: %A" ar //let ar2 = array |> Array.sum //let ar3 = ar2 //let br = ar3 / n //let br = ar //printfn "Π‘ΡΠ΅Π΄Π½Π΅Π΅ Π°ΡΠΈΡΠΌΠ΅ΡΠΈΡΠ΅ΡΠΊΠΎΠ΅ ΡΠ»Π΅ΠΌΠ΅Π½ΡΠΎΠ² ΡΠΏΠΈΡΠΊΠ° 2: %A" br Console.ReadLine() |> ignore Why in the end is the arithmetic mean zero? If during debugging correctly calculates both the number n and the sum of the elements of the array itself?