Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ruby Judo Challenge #111

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added uniques program
robdrosenberg committed Sep 29, 2016
commit 9f4128e54a299dd26468df6143207396bc70ef7e
20 changes: 16 additions & 4 deletions problems1-6.rb
Original file line number Diff line number Diff line change
@@ -13,13 +13,25 @@ def power(base, exponent)
#-----------------------------------------
#Factorial--------------------------------
def factorial(num)
multiples = (1..num).to_a
total = 1
multiples.each do |n|
(1..num).each do |n|
total = total * n
end
return total
puts total
end

puts factorial(5)
#-----------------------------------------
#-----------------------------------------
#Uniques----------------------------------
def uniques(array)
unique_array = []
array.each do |item|
if unique_array.include?(item) == false
unique_array.push(item)
end
end
puts unique_array
end

uniques([1,5,"frog",2,1,3,"frog"])
#-----------------------------------------