Home > Backend Development > PHP Tutorial > 两数是质数,两数积为217,求这两数,该如何处理

两数是质数,两数积为217,求这两数,该如何处理

WBOY
Release: 2016-06-13 13:28:12
Original
1380 people have browsed it

两数是质数,两数积为217,求这两数
两数是质数,两数积为217,求这两数

------解决方案--------------------
因式分解(筛法)

PHP code
function Factorization($num) {
  $end = sqrt($num);
  $k = 1;
  for($i=2; $i 1) $r[] = $num;
  return $r;
}

print_r(Factorization(217));
<br><font color="#e78608">------解决方案--------------------</font><br>穷举吧...<br>for($i=1;$i{<br>  $v = 217/$i;<br>  if($v%2==1&&$i%2==1)<br>  {<br>      break;<br>  }<br>}<br>echo "$v*$i=217;并$v $i 为质数.";
<br><font color="#e78608">------解决方案--------------------</font><br>
Copy after login
PHP code

for($i=3;$i<sqrt echo class="clear">
                 
              
              
        
            </sqrt>
Copy after login
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