Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cours
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
radhwan.hassine
cours
Commits
c1dde36d
Verified
Commit
c1dde36d
authored
3 years ago
by
orestis.malaspin
Browse files
Options
Downloads
Patches
Plain Diff
updated course on fibonacci and recursion
parent
e8d39dab
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
slides/cours_5.md
+36
-0
36 additions, 0 deletions
slides/cours_5.md
with
36 additions
and
0 deletions
slides/cours_5.md
+
36
−
0
View file @
c1dde36d
...
@@ -850,6 +850,42 @@ int pgcd(int n, int m) {
...
@@ -850,6 +850,42 @@ int pgcd(int n, int m) {
}
}
```
```
# La suite de Fibonacci
## Règle
$$
\m
athrm{Fib}(n) =
\m
athrm{Fib}(n-1) +
\m
athrm{Fib}(n-2),
\q
uad
\m
athrm{Fib}(0)=0,
\q
uad
\m
athrm{Fib}(1)=1.
$$
## Exercice: écrire la fonction $\mathrm{Fib}$ en récursif et impératif
```
C
int fib(int n) {
if (n > 1) {
return fib(n - 1) + fib(n - 2);
} else {
return n;
}
}
```
```
C
int fib_imp(int n) {
int fib0 = 1;
int fib1 = 1;
int fib = n == 0 ? 0 : fib1;
for (int i = 2; i < n; ++i) {
fib = fib0 + fib1;
fib0 = fib1;
fib1 = fib;
}
return fib;
}
```
# Exercices pour les semaines sans cours
# Exercices pour les semaines sans cours
## Quelques algorithmes à réaliser et poster sur matrix
## Quelques algorithmes à réaliser et poster sur matrix
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment