PROGRAM Summation !----------------------------------------------------------------------- ! Program to find the smallest positive integer Number for which the ! sum 1 + 2 + ... + Number is greater than some specified value Limit. ! Variables used are: ! Number : the current number being added ! Sum : the sum 1 + 2 + ... + Number ! Limit : the value which Sum is to exceed ! ! Input: An integer Limit ! Output: Number and the value of Sum !----------------------------------------------------------------------- IMPLICIT NONE INTEGER :: Number, Sum, Limit ! Read Limit and initialize Number and Sum PRINT *, "Enter value that 1 + 2 + ... + ? is to exceed:" READ *, Limit Number = 0 Sum = 0 ! Repeat--terminate when Sum exceeds Limit DO IF (Sum > Limit) EXIT ! terminate repetition ! otherwise continue with the following: Number = Number + 1 Sum = Sum + Number END DO ! Print the results PRINT *, "1 + ... +", Number, "=", Sum, ">", Limit END PROGRAM Summation