I am preparing for an exam, and working through some practice questions, which unfortunately does not provide solutions. I would like to program this function using the SUM function, an array constructor and an implied do-loop:
Sum from n=2 to 100, (1+2*N)*LOG10(N)
I have tried:
WRITE(*,*) SUM(real:: x(99) = (/ ( (1+2*N)*LOG10(REAL(N)) , N=2,100 ) /))
But all the IDE says is that the statement is not recognised. I have tried a variety of other ways, but no luck.
It is not allowed to have the declaration of
x
inside a statement. Also, it is not required, you can process the implied loop directly:This gives