You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A primality test is an algorithm for determining whether an input number is prime.
558
-
Among other fields of mathematics, it is used for cryptography.
559
-
Unlike integer factorization, primality tests do not generally give prime factors, only stating whether the input number
560
-
is prime or not. Factorization is thought to be a computationally difficult problem, whereas primality
561
-
testing is comparatively easy (its running time is polynomial in the size of the input).
562
-
Some primality tests prove that a number is prime, while others like Miller–Rabin prove that a number is composite.
566
+
Among other fields of mathematics, it is used for cryptography.
567
+
Unlike integer factorization, primality tests do not generally give prime factors, only stating whether the input number
568
+
is prime or not. Factorization is thought to be a computationally difficult problem, whereas primality
569
+
testing is comparatively easy (its running time is polynomial in the size of the input).
570
+
Some primality tests prove that a number is prime, while others like Miller–Rabin prove that a number is composite.
563
571
Therefore, the latter might be called compositeness tests instead of primality tests.
564
572
565
573
566
574
#### Miller-Rabin Primality Test
567
-
568
-
The Miller–Rabin primality test or Rabin–Miller primality test is a primality test: an algorithm which determines whether a given number is prime,
569
-
similar to the Fermat primality test and the Solovay–Strassen primality test. Its original version, due to Gary L. Miller, is deterministic,
575
+
576
+
The Miller–Rabin primality test or Rabin–Miller primality test is a primality test: an algorithm which determines whether a given number is prime,
577
+
similar to the Fermat primality test and the Solovay–Strassen primality test. Its original version, due to Gary L. Miller, is deterministic,
570
578
but the correctness relies on the unproven Extended Riemann hypothesis; Michael O. Rabin modified it to obtain an unconditional probabilistic algorithm.
571
579
572
580
```python
@@ -575,7 +583,7 @@ from py_algorithms.primality_tests import new_miller_rabin_primality_test
575
583
algorithm = new_miller_rabin_primality_test()
576
584
577
585
algorithm(199) #=> True, 199 is a prime number
578
-
algorithm(4) #=> False, 4 % 2 == 0, therefore, 4 is not a prime number.
586
+
algorithm(4) #=> False, 4 % 2 == 0, therefore, 4 is not a prime number.
579
587
580
588
```
581
589
@@ -590,12 +598,40 @@ from py_algorithms.primality_tests import new_simple_primality_test
590
598
algorithm = new_simple_primality_test()
591
599
592
600
algorithm(32416190071) #=> True, 32416190071 is a prime number
593
-
algorithm(4) #=> False, 4 % 2 == 0, therefore, 4 is not a prime number.
601
+
algorithm(4) #=> False, 4 % 2 == 0, therefore, 4 is not a prime number.
594
602
595
603
```
596
604
597
605
---
598
606
607
+
### Dynamic Programing (DP)
608
+
In computer science, mathematics, management science, economics and bioinformatics,
609
+
dynamic programming (also known as dynamic optimization) is a method for solving a complex problem
610
+
by breaking it down into a collection of simpler subproblems, solving each of those subproblems
611
+
just once, and storing their solutions. The next time the same subproblem occurs,
612
+
instead of recomputing its solution, one simply looks up the previously computed solution,
613
+
thereby saving computation time at the expense of a (hopefully) modest expenditure in storage space.
614
+
(Each of the subproblem solutions is indexed in some way, typically based on the values of its input parameters,
615
+
so as to facilitate its lookup.) The technique of storing solutions to subproblems instead of recomputing them is called "memoization".
616
+
617
+
618
+
###
619
+
In information theory, Linguistics and computer science, the Levenshtein distance is a string metric for measuring the difference between two sequences.
620
+
Informally, the Levenshtein distance between two words is the minimum number of single-character edits (insertions, deletions or substitutions) required to change one word into the other.
621
+
It is named after Vladimir Levenshtein, who considered this distance in 1965.
622
+
Levenshtein distance may also be referred to as edit distance, although that term may also denote a larger family of distance metrics.
623
+
624
+
It is closely related to pairwise string alignments.
625
+
626
+
```python
627
+
from py_algorithms.strings import new_levenshtein_distance
0 commit comments