怎样判断一个较大的数是不是质数?

  • 时间:2020-04-08 16:22:25
  • 分类:数学世界
  • 阅读:98 次

怎样判断一个较大的数是不是质数?同学们已经熟悉了100以内的质数表:2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97。会查表断定一个数是不是质数,但有时需要判定一个较大的数是不是质数。例如:把2995分解质因数,可以借助短除法,

短除法

197能否继续往下分解,要看197是不是质数。因为197比100大,所以从100以内的质数表里是查不到了。除了查更大的质数表外,我们介绍一种判断质数的方法。

例如:判断197是不是质数。

根据能被2、3、5、7、11整除的数的特征断定197不能被质数2、3、5、7、11整除,再用13,17,19……去试除:

197÷13=15……2

197÷17=11……10

由于用17去试除时,商11已经比17小,因而可断定197再不可能被比17大的质数整除了。因为,如果197能被17大的质数整除,那么所得的商一定比17小。也就是说197有比17小的质因数。但经过试除知道,比17小的质数都不是197的因数。由此可以肯定197就是质数了。

这种判断方法实际上是试除法。即由小到大的质数一个个地去除,如果发现所给的数能被某一个质数整除,它就是合数;如果除到商比试除的质数小还未能整除,即可断定所给的数就是质数了。

例如:判断167是不是质数。

解:经判断167不能被2、3、5、7、11等质数整除,再用13试除:

167÷13=12……11

因为12<13,此时仍未整除,所以167是质数。

推荐阅读:
How to Monitor the CPU Temperature of Raspberry PI using Python   Listen to what an SEO expert has to say about its benefits  Depth First Search Algorithm to Compute the Smallest String Star  Algorithm to Check if All Points are On the Same Line  Prefix Sum Algorithm to Count Number of Nice Subarrays  How to Append Another List to a Existing List in Python? (Differ  Linear Algorithm to Check If All 1’s Are at Least Length K  Finding the Root of a Tree (Finding the Common Destination)  Does WIFI Extender Boost Wireless Signal? How to Fix Slow WIFI?  Bruteforce with Memoization to Count the Square Digit Chains 
评论列表
添加评论