Combination Finder

2015-08-31 0 309
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

遇见资源网 ruby Combination Finder http://www.ox520.com/16445.html

常见问题

相关文章

发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务