PROGRAM ADDER2 ************************************************************************ * Program that uses a DO WHILE statement 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 DO WHILE (SUM .LE. LIMIT) NUMBER = NUMBER + 1 SUM = SUM + NUMBER END DO * Print the results PRINT *, '1 + ... +', NUMBER, ' =', SUM, ' >', LIMIT END