! ===================================================	
! SerieSum: Demo function definition
! ===================================================

! ===================================================	
! Function returns a + (a+1) + ... + b
! ===================================================
	FUNCTION SerieSum(a, b)
	IMPLICIT NONE										 
	INTEGER, INTENT(IN) :: a
	INTEGER, INTENT(IN) :: b

	INTEGER SerieSum	!! Return type (return variable)
 
	INTEGER :: i

	SerieSum = 0

	DO i = a, b
		 SerieSum = SerieSum + i
	END DO

	RETURN
	END

! ===================================================

	PROGRAM Demo
	IMPLICIT NONE										 
!       REAL    x, y
        INTEGER x, y
        INTEGER sum

	INTEGER, EXTERNAL :: SerieSum

	print*, "Program somputes a + (a+1) + ... + b"
	print*, "Start number a = "
	read*, x
	print*, "End number b = "
	read*, y

	sum = SerieSum(x,y)

	print*, "Serie sum = ", sum
	print*
	STOP
	END

