如何找到一个数字是否可分解为正好两个素数? [英] how to find if a number is breakable into exactly 2 prime factors?

查看:413
本文介绍了如何找到一个数字是否可分解为正好两个素数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检查一个数字是否可分解为2个素数(恰好是2个)例如21 = 7 * 335 = 5 * 7我无法为此目的找出任何标准程序.有没有算法可以做到这一点?

I want to check if a number is breakable into 2 prime factors (exactly 2) for example 21=7*3 35=5*7 i am unable to figure out any standard procedure for this purpose. is there any algorithm to do this.?

推荐答案

您可以使用以下参考.

  1. http://www.geeksforgeeks.org/sieve-of-eratosthenes/
  2. http://www.geeksforgeeks.org/prime-factorization-using-sieve-olog-n-multiple-queries/

除了橡皮擦筛网外,还使用分段筛网,>://www.geeksforgeeks.org/exactly-n-distinct-prime-factor-numbers-b/

Apart form sieve of eratosthene use segmented sieve, http://www.geeksforgeeks.org/exactly-n-distinct-prime-factor-numbers-b/

这篇关于如何找到一个数字是否可分解为正好两个素数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆