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

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

WBOY
WBOYOriginal
2016-06-13 10:26:531551browse

两数是质数,两数积为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>
PHP code
for($i=3;$i<sqrt class="clear">
                 
              
              
        
            </sqrt>
Statement:
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