factorial_gem 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/factorial_gem.rb +44 -0
- metadata +44 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: d5c51995136018d43c6a1b43d5ef1f564caf4d4b
|
|
4
|
+
data.tar.gz: 29528a38baec55a48fb4967be44280aaf85c7877
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: b2fe48932adb5d66e917c51300e2cedd9094067d438971afae8a8e04645d4be2caadebdc9cffa0e212e7d8168bfdb8bdb40f40b0da30554ac480e052ecba0183
|
|
7
|
+
data.tar.gz: 5026e898c8082f5118a1420f5c02264ce1e78bfc9d0458d8c37d867753862a82e12e45545c02727a6610aba462816ef162f94dd30329b09138d275cd6c69670e
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
module FactorialGem
|
|
2
|
+
class Factorial
|
|
3
|
+
def factor
|
|
4
|
+
puts"\nFind Factorial enter 1 \nFind nCr value enter 2 \nFind nPr value enter 3"
|
|
5
|
+
print"enter to go: "
|
|
6
|
+
select = STDIN.gets.to_i
|
|
7
|
+
if select == 1
|
|
8
|
+
puts"Factorial"
|
|
9
|
+
def factorial(n=0)
|
|
10
|
+
(1..n).inject(:*)
|
|
11
|
+
end
|
|
12
|
+
print "enter no: "
|
|
13
|
+
n = STDIN.gets.to_i
|
|
14
|
+
val = factorial(n)
|
|
15
|
+
puts "#{n} factorial is #{val}"
|
|
16
|
+
end
|
|
17
|
+
if select == 2
|
|
18
|
+
puts"nCr value"
|
|
19
|
+
print "enter n value: "
|
|
20
|
+
n = STDIN.gets.to_i
|
|
21
|
+
def factorial(n)
|
|
22
|
+
(n...r).inject(:*)
|
|
23
|
+
end
|
|
24
|
+
print "enter r value: "
|
|
25
|
+
r = STDIN.gets.to_i
|
|
26
|
+
def factorial(r)
|
|
27
|
+
(1..r).inject(:*)
|
|
28
|
+
end
|
|
29
|
+
val = factorial(n) / factorial(r)
|
|
30
|
+
puts "value of nCr: #{val}"
|
|
31
|
+
end
|
|
32
|
+
if select == 3
|
|
33
|
+
puts"nPr value"
|
|
34
|
+
print "enter n value: "
|
|
35
|
+
n = STDIN.gets.to_i
|
|
36
|
+
print "enter r value: "
|
|
37
|
+
r = STDIN.gets.to_i
|
|
38
|
+
c = (r..n).inject(:*)
|
|
39
|
+
puts c
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: factorial_gem
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Rk
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-06-09 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description:
|
|
14
|
+
email: rk.ramakrishna11#gmail.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- lib/factorial_gem.rb
|
|
20
|
+
homepage: http://rubygems.org/gems/factorial
|
|
21
|
+
licenses:
|
|
22
|
+
- MIT
|
|
23
|
+
metadata: {}
|
|
24
|
+
post_install_message:
|
|
25
|
+
rdoc_options: []
|
|
26
|
+
require_paths:
|
|
27
|
+
- lib
|
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
34
|
+
requirements:
|
|
35
|
+
- - ">="
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '0'
|
|
38
|
+
requirements: []
|
|
39
|
+
rubyforge_project:
|
|
40
|
+
rubygems_version: 2.5.1
|
|
41
|
+
signing_key:
|
|
42
|
+
specification_version: 4
|
|
43
|
+
summary: factorial_gem is the best
|
|
44
|
+
test_files: []
|