I started playing with F#…

I decided to do some Project Euler problems using F#. 

So here is my first one, Problem # 31.  Nothing in this solution really shows off anything special about F# but you have to start somewhere ;)

let rec combos amt (denoms:int list) =
   if amt = 0 then 1
   elif denoms.IsEmpty || amt < 0 then 0
   else
       combos (amt – denoms.Head) denoms +
       combos amt denoms.Tail

printf "\n\nThe Anwer is: %i \n" (combos 200 [200;100;50;20;10;5;2;1])
This entry was posted in F#. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>