Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RSA
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
nicolas.albanesi
RSA
Merge requests
!2
Resolve "Create Function find_p_q"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "Create Function find_p_q"
2-create-function-find_p_q
into
main
Overview
0
Commits
2
Pipelines
0
Changes
3
Merged
abivarma.kandiah
requested to merge
2-create-function-find_p_q
into
main
3 years ago
Overview
0
Commits
2
Pipelines
0
Changes
3
Expand
Closes
#2 (closed)
Edited
3 years ago
by
abivarma.kandiah
0
0
Merge request reports
Compare
main
main (base)
and
latest version
latest version
56b3be89
2 commits,
3 years ago
3 files
+
94
−
0
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
3
Search (e.g. *.vue) (Ctrl+P)
src/euclide.py
0 → 100644
+
55
−
0
Options
'''
Description : Calcule le PGCD de deux nombres et leurs
coefficients de bezout
Return : PGCD, Coef de X, Coef de Y
(X est le nombre le plus grand)
'''
def
pgcd_etendu
(
a
,
b
):
a
,
b
=
abs
(
a
),
abs
(
b
)
# On s'assure que le plus grand nombre est a
#if b > a:
#b,a = a,b
# Vérification que le plus petit nombre n'est pas 0
assert
(
not
(
b
==
0
))
r
=
[
None
]
*
100
q
=
[
None
]
*
100
x
=
[
None
]
*
100
y
=
[
None
]
*
100
etape
=
2
# Phase d'initialisation
r
[
0
]
=
a
x
[
0
]
=
1
y
[
0
]
=
0
r
[
1
]
=
b
x
[
1
]
=
0
y
[
1
]
=
1
while
(
r
[
etape
-
1
]
!=
0
):
r
[
etape
]
=
a
%
b
q
[
etape
]
=
a
//
b
x
[
etape
]
=
x
[
etape
-
2
]
-
q
[
etape
]
*
x
[
etape
-
1
]
y
[
etape
]
=
y
[
etape
-
2
]
-
q
[
etape
]
*
y
[
etape
-
1
]
a
,
b
=
b
,
r
[
etape
]
etape
+=
1
return
r
[
etape
-
2
],
x
[
etape
-
2
],
y
[
etape
-
2
]
def
pgcd_etendu_verif
(
a
,
b
,
x
,
y
,
pgcd
):
if
(
pgcd
==
(
a
*
x
+
b
*
y
)):
return
True
return
False
if
__name__
==
'
__main__
'
:
b
=
4991
a
=
1197
print
(
pgcd_etendu
(
a
,
b
))
pgcd
,
x
,
y
=
pgcd_etendu
(
a
,
b
)
print
(
pgcd_etendu_verif
(
a
,
b
,
x
,
y
,
pgcd
))
\ No newline at end of file
Loading