program re_Calculates_N implicit none integer :: a , sum_N , N , S S=1 do while ( S==1) write(*,*) " Calculate 1 + 2 + ... + N " write(*,*) " Please input is bigger than zero the integer N " a=1 sum_N=0 read (*,*) N do a=1 , N sum_N=sum_N+a end do write(*,*)"The answer of 1 + 2 + ... + " , N , " is" , sum_N write(*,*)" Recalulate , Please input integer 1 " write(*,*)" Leaves the program , Please input not equal to 1" read(*,*) S end do stop end program re_Calculates_N