Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tp_rsa_python
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
flavio.morrone
tp_rsa_python
Commits
38cdacc5
Commit
38cdacc5
authored
2 years ago
by
adrian.spycher
Browse files
Options
Downloads
Patches
Plain Diff
add comment
parent
a9b9718a
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
algo.py
+3
-2
3 additions, 2 deletions
algo.py
with
3 additions
and
2 deletions
algo.py
+
3
−
2
View file @
38cdacc5
...
...
@@ -79,7 +79,7 @@ def exponentiation_rapide(a, exp, n):
def
is_square
(
a
):
"""
Check if a number is a perfect square, based on the
"
Babylonian algorithm
"
for square root,
"""
Check if a number is a perfect square, based on the
"
Babylonian algorithm
"
(Héron
'
s method)
for square root,
from : https://stackoverflow.com/questions/2489435/check-if-a-number-is-a-perfect-square
Args:
...
...
@@ -93,7 +93,7 @@ def is_square(a):
seen
=
set
([
x
])
while
x
*
x
!=
a
:
x
=
(
x
+
(
a
//
x
))
//
2
x
=
(
x
+
(
a
//
x
))
//
2
# arithmetic average
if
x
in
seen
:
return
False
...
...
@@ -131,6 +131,7 @@ def fermat_factorization(n):
b
=
int
(
math
.
sqrt
(
b2
))
return
(
a
,
b
)
def
decode_msg
(
M
):
"""
Decode a code UTF-8 in characters
from : Niklaus Eggenberg
...
...
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