Find whether two numbers are mutually prime (coprime)

WBOY
Release: 2016-07-25 08:48:27
Original
1663 people have browsed it
Use the euclidean method to find out whether two numbers are prime numbers (prime numbers)
  1. $a=200;
  2. $b=13;
  3. //Euclidean division method
  4. if($b>$a){
  5. $x=$a;$a=$b;$ b=$x;
  6. }
  7. while(1){
  8. //echo "a=".$a." b=".$b;echo "n";
  9. if($b==1){echo " Reciprocally prime";break;}
  10. if($b==0){echo "Not reciprocally prime";break;}
  11. if($a-$b > $b){
  12. $a=$a-$b ;
  13. }else{
  14. $a=$a-$b;
  15. $x=$a;$a=$b;$b=$x;
  16. }
  17. }
  18. ?>
Copy code


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template