%%% -*- mode: erlang -*-
%%% $Id: sumcol.erlang,v 1.2 2000/12/31 18:56:43 doug Exp $
%%% http://www.bagley.org/~doug/shootout/

-module(sumcol).
-export([main/0, main/1]).


main() -> main(['1']).
main(Args) ->
    io:put_chars( sumcol( io:fread( '', "~d" ), 0) ),
    halt(0).

sumcol( eof, Sum ) ->
        io_lib:format( "~w~n", [Sum] );
sumcol( {ok, [N]}, Sum ) ->
    io:put_chars( io_lib:format( "~w~n", [Sum] ) ),
    sumcol( io:fread( '', "~d" ), Sum + N ).