Combination Finder

def factorial(n)
  if n==0
    return 1
  else
    return n*factorial(n-1)
  end
end

def combination(x,y)
  if y>x
    puts "Invalid Input!"
  else
    result=factorial(x)/(factorial(x-y)*factorial(y))
    puts "The combination is "+result.to_s
  end
end

编程技巧