Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
MIS21
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Owen Ilagan
MIS21
Commits
81b59891
Commit
81b59891
authored
Jun 16, 2016
by
Owen Ilagan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more revisions
parent
fda54af5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
0 deletions
+23
-0
fibonacci.rb
_class_exercises/fibonacci.rb
+23
-0
manual_sort.rb
_class_exercises/manual_sort.rb
+0
-0
other.rb
_class_exercises/other.rb
+0
-0
ruby_demo.rb
_class_exercises/ruby_demo.rb
+0
-0
No files found.
_class_exercises/fibonacci.rb
0 → 100644
View file @
81b59891
def
get_fibonacci
(
length
)
# This function produces an array containing integers representing
# a Fibonacci sequence of a given length
result
=
[]
length
.
times
do
|
idx
|
if
idx
==
0
# At the start of the loop just push the initial number
result
.
push
(
1
)
elsif
idx
==
1
# At the second iteration just push another number
result
.
push
(
1
)
else
a
=
result
[
idx
-
2
]
# Getting the last two numbers in the array
b
=
result
[
idx
-
1
]
nextnum
=
a
+
b
# Add the last two numbers of the array
result
.
push
(
nextnum
)
end
end
return
result
end
n
=
10
puts
get_fibonacci
(
n
).
join
(
','
)
manual_sort.rb
→
_class_exercises/
manual_sort.rb
View file @
81b59891
File moved
other.rb
→
_class_exercises/
other.rb
View file @
81b59891
File moved
ruby_demo.rb
→
_class_exercises/
ruby_demo.rb
View file @
81b59891
File moved
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment