mirror of
https://github.com/c0de-archive/hacktoberfest-2018.git
synced 2024-09-29 01:57:37 +00:00
Merge pull request #20 from cynferdd/master
update to readme.md : added "cynferdd" entry + fibonacci ruby script
This commit is contained in:
commit
6c504af23e
@ -73,6 +73,12 @@ Start adding your names here:
|
|||||||
- [![twitter-alt][twitter-img]](https://twitter.com/shubhamnishad97)
|
- [![twitter-alt][twitter-img]](https://twitter.com/shubhamnishad97)
|
||||||
[![github-alt][github-img]](https://github.com/shubhamnishad97)
|
[![github-alt][github-img]](https://github.com/shubhamnishad97)
|
||||||
|
|
||||||
|
### Mathieu Jolivet (Cynferdd)
|
||||||
|
- Developper as a hobby since 1996, professionaly since 2005.
|
||||||
|
- Bass player, I also love reading, photography and beer.
|
||||||
|
- [![twitter-alt][twitter-img]](https://twitter.com/cynferdd)
|
||||||
|
[![github-alt][github-img]](https://github.com/cynferdd)
|
||||||
|
|
||||||
### Example Profile
|
### Example Profile
|
||||||
- I'm an example that you can copy, if you want :)
|
- I'm an example that you can copy, if you want :)
|
||||||
- I work for...
|
- I work for...
|
||||||
|
21
code/fibonacci.rb
Normal file
21
code/fibonacci.rb
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#####################
|
||||||
|
# Fibonacci in Ruby #
|
||||||
|
#####################
|
||||||
|
# main fibonacci function
|
||||||
|
def CalculateFibonacci(n)
|
||||||
|
if (n == 0)
|
||||||
|
return 0
|
||||||
|
elsif (n <= 2)
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
return CalculateFibonacci(n - 1) + CalculateFibonacci(n - 2)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
# execution with check regarding the amount of args
|
||||||
|
if(ARGV.length < 1)
|
||||||
|
puts "argument needed. term number to iterate to, with 0 as the first term number"
|
||||||
|
else
|
||||||
|
for arg in ARGV
|
||||||
|
puts arg.to_s + ": " + CalculateFibonacci(arg).to_s
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user