C Program to find the sum of GP series
print*,'Enter the number of terms, 1st term and common ratio:'
read(*,*)n,a,r
sum=0
do i=0,n-1
sum=sum+a*r**i
end do
write(*,*)'The sum of the GP series is',sum
end
print*,'Enter the number of terms, 1st term and common ratio:'
read(*,*)n,a,r
sum=0
do i=0,n-1
sum=sum+a*r**i
end do
write(*,*)'The sum of the GP series is',sum
end
Comments
Post a Comment