- #1
Boltzmann
- 7
- 2
Hello there,
I again have a problem with programming in Fortran 90.1. Homework Statement
I would like to construct an array with an implicit do loop.
I know how to get the array I want to with usual do-loop but I would like to do it without do loops.
So this is the array I want to construct:
a(0:f)
a(0)=4
DO i=1,f
a(i)=a(i-1)+4*(-1)**i*1/(2*i+1)
ENDDO
So, I want get this array, without using an explicit do-loop.
For example, I know, that the implicit do-loops work like this:
a=(/(i+1,i=1,5)/)
But it doesn't work with recursion. So what I've tried for my array is:
a(0)=4
a=(/(a(i-1)+4*(-1)**i*1/(2*i+1),i=1,f)/)
It doesn't work at all.
Does someone know how to use this in the right way or maybe any other solutions to construct the array without an explicit do-loop.Many thanks in advance.
greets Boltzmann
I again have a problem with programming in Fortran 90.1. Homework Statement
I would like to construct an array with an implicit do loop.
I know how to get the array I want to with usual do-loop but I would like to do it without do loops.
So this is the array I want to construct:
a(0:f)
a(0)=4
DO i=1,f
a(i)=a(i-1)+4*(-1)**i*1/(2*i+1)
ENDDO
So, I want get this array, without using an explicit do-loop.
For example, I know, that the implicit do-loops work like this:
a=(/(i+1,i=1,5)/)
But it doesn't work with recursion. So what I've tried for my array is:
a(0)=4
a=(/(a(i-1)+4*(-1)**i*1/(2*i+1),i=1,f)/)
It doesn't work at all.
Does someone know how to use this in the right way or maybe any other solutions to construct the array without an explicit do-loop.Many thanks in advance.
greets Boltzmann