Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TD_Debug
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
MARCHAL Aurelien
TD_Debug
Commits
7fdc8617
Commit
7fdc8617
authored
1 week ago
by
MARCHAL Aurelien
Browse files
Options
Downloads
Patches
Plain Diff
Exercice 8 : Factorielle et recursivité
parent
6616f9c5
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
qualdev/TD-Debug.ts
+29
-7
29 additions, 7 deletions
qualdev/TD-Debug.ts
with
29 additions
and
7 deletions
qualdev/TD-Debug.ts
+
29
−
7
View file @
7fdc8617
...
...
@@ -123,12 +123,34 @@ function multiplicationParAddition(x: number, y: number): number {
}
let
couples
=
[
[
0
,
0
],
[
5
,
3
],
[
3
,
5
],
[
-
5
,
-
2
],
[
-
2
,
-
5
],
[
-
74
,
2
],
[
-
1
,
75
],
[
10
,
-
25
],
[
10
,
-
3
]
];
//
let couples = [
//
[0, 0], [5, 3], [3, 5], [-5, -2], [-2, -5],
//
[-74, 2], [-1, 75], [10, -25], [10, -3]
//
];
for
(
let
[
x
,
y
]
of
couples
)
{
console
.
log
(
`multiplicationParAddition(
${
x
}
,
${
y
}
) =
${
multiplicationParAddition
(
x
,
y
)}
`
);
//for (let [x, y] of couples) {
// console.log(`multiplicationParAddition(${x}, ${y}) = ${multiplicationParAddition(x, y)}`);
//}
//exo 8 :
let
n
=
5
;
console
.
log
(
factorielle
(
n
));
function
factorielle
(
n
:
number
):
number
{
if
(
n
===
0
)
{
return
1
;
}
\ No newline at end of file
let
valeur
=
n
*
factorielle
(
n
-
1
);
return
valeur
;
}
function
factorielle2
(
n
:
number
):
number
{
if
(
n
<
0
)
throw
new
Error
(
"
Valeur non valide pour la factorielle
"
);
if
(
n
===
0
)
return
1
;
return
n
*
factorielle2
(
n
-
1
);
}
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