PROGRAM Tester
    IMPLICIT NONE

    CALL Newton(1.23)
    CALL Newton(456.7)
    CALL Newton(8.9e5)

CONTAINS

    SUBROUTINE Newton (value)
        IMPLICIT NONE
        REAL, INTENT(IN) :: value
        REAL :: solution, last, previous

        IF ( value < 1.0) THEN
            PRINT *, 'Value of X*LOG(X) out of range'
            RETURN
        END IF
        solution = value            
        last = 2.0*value
        previous = 3.0*value
        DO
            solution = solution - &
                (Fn1(solution) - value) / Fn2(solution)
            IF (solution == last .OR. solution == previous) EXIT
            previous = last
            last = solution
        END DO
        PRINT *, 'X*LOG(X) =', value, '    X =', solution
    END SUBROUTINE Newton

    PURE FUNCTION Fn1 (arg)
        IMPLICIT NONE
        REAL :: Fn1
        REAL, INTENT(IN) :: arg

        Fn1 = arg*LOG(arg)
    END FUNCTION Fn1

    PURE FUNCTION Fn2 (arg)
        IMPLICIT NONE
        REAL :: Fn2
        REAL, INTENT(IN) :: arg

        Fn2 = LOG(arg)+1.0
    END FUNCTION Fn2

END PROGRAM Tester
