Faffing round the edges Its easier than getting stuck in

28Dec/080

Problem 13: Work out the first ten digits of the sum of the following one-hundred 50-digit numbers.

This is not a tough problem for lisp or erlang. Some bright spark in the forum simply states that he cut and paste the list and wrapped it with (+ ) and had the result. I think the size of the numbers presents problems for some languages and the optimization is to only sum the first eleven digits of the long numbers since we only need the first 10 digits of the result.

I am lazy so I went the cut and paste option...

prob13() ->
    BigNumbers = [ELIDED],
    lists:sublist(integer_to_list(lists:sum(BigNumbers)), 1, 10).

So sum the list and then take the first 10 digits of the result. If you want to see the list of numbers they are here.

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

You must be logged in to post a comment.

No trackbacks yet.

 

December 2008
M T W T F S S
« Nov   Mar »
1234567
891011121314
15161718192021
22232425262728
293031  

Archives