In [1]:
# Part A
function A(M)
    r = 0
    for n = 1:M
        r = r + sqrt(n)
    end
    return r
end


Out[1]:
A (generic function with 1 method)

In [2]:
# Part B
function B(M)
    r = 0
    for n = 1:M
        r = r + log(n)
    end
    return r
end


Out[2]:
B (generic function with 1 method)

In [3]:
# Part C
function C(M)
    r = 1
    for n = 1:M
        r = r * (cos(n*pi/10)^2+0.1)
    end
    return r
end


Out[3]:
C (generic function with 1 method)

In [4]:
# Part D
## The product is independent to i, though it can be written as
function D1(M, x)
  return (1+exp(x))^(M/2)
end
## If the x is wrong and is supposed to be an i, the function is
function D2(M)
    r = 1
    for n = 1:M
        r = r * sqrt(1+exp(i))
    end
    return r
end


Out[4]:
D2 (generic function with 1 method)

In [ ]: