Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix comments
  • Loading branch information
Erfaniaa committed May 27, 2019
commit 4e10b6a79aff888f0369b393452c55e656746dd3
3 changes: 1 addition & 2 deletions maths/fermat_little_theorem.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# Python program to show the usage of Fermat's little theorem in a division
# Time complexity: O(log p)
# According to Fermat's little theorem, (a / b) mod p always equals a * (b ^ (p - 2)) mod p
# Here we assume that p is a prime number, b divides a, and p doesn't divide b

Expand All @@ -23,7 +22,7 @@ def binary_exponentiation(a, n, mod):
a = 1000000000
b = 10

# using binary exponentiation function:
# using binary exponentiation function, O(log(p)):
print((a / b) % p == (a * binary_exponentiation(b, p - 2, p)) % p)

# using Python operators:
Expand Down