0 Replies - 1057 Views - Last Post: 08 November 2010 - 08:01 AM

#1 Sergio Tapia   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1258
  • View blog
  • Posts: 4,168
  • Joined: 27-January 10

F# - Calculate factorials.

Posted 08 November 2010 - 08:01 AM

Description: Just paste it anywhere inside a .fs file and it'll work.This snippet shows you how to calculate factorials using F# and recursive functions.
#light
open System

let rec getFactorial n =
    if n < 1 then 1
    else n * getFactorial (n - 1)

Console.WriteLine(getFactorial 5)

Is This A Good Question/Topic? 0
  • +

Page 1 of 1