      PROGRAM ADDER2
************************************************************************
* Program that uses a DO WHILE structure to find the smallest positive *
* integer NUMBER for which the sum 1 + 2 + ... + NUMBER is greater     *
* than some specified 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                                  *
************************************************************************

      INTEGER NUMBER, SUM, LIMIT

* Read LIMIT and initialize NUMBER and SUM

      PRINT *, 'ENTER VALUE 1 + 2 + ... + ? IS TO EXCEED'
      READ *, LIMIT
      NUMBER = 0
      SUM = 0

* While SUM does not exceed LIMIT, increment NUMBER and add to SUM

10    IF (SUM .LE. LIMIT) THEN
          NUMBER = NUMBER + 1
          SUM = SUM + NUMBER
          GO TO 10
      END IF

* Print the results

      PRINT *, '1 + ... +', NUMBER, ' =', SUM, ' >', LIMIT
      END

