质数是只能被自身和一个整数整除的数字。这些质数还可以除以其他数,因此它们成为这些数的一个因数。例如,5是质数,它也除以20。要查找数字的质因数,我们可以使用数字包的primeFactors函数。
library(numbers)
primeFactors(100)
[1] 2 2 5 5
primeFactors(1000)
[1] 2 2 2 5 5 5
primeFactors(32547)
[1] 3 19 571
primeFactors(12354767)
[1] 17 726751
primeFactors(21457)
[1] 43 499
primeFactors(99)
[1] 3 3 11
primeFactors(365748)
[1] 2 2 3 29 1051
primeFactors(214687)
[1] 11 29 673
primeFactors(3587497)
[1] 3587497
primeFactors(35874)
[1] 2 3 3 1993
primeFactors(268713)
[1] 3 3 73 409
primeFactors(298473)
[1] 3 7 61 233
primeFactors(236571)
[1] 3 78857
primeFactors(98753)
[1] 17 37 157
primeFactors(547821)
[1] 3 3 60869
primeFactors(3652147)
[1] 23 97 1637
primeFactors(6985147)
[1] 13 17 31607
primeFactors(1236587469)
[1] 3 13 19 131 12739
primeFactors(65214693)
[1] 3 3 3 2415359
primeFactors(326579)
[1] 11 11 2699
primeFactors(1236574)
[1] 2 618287
primeFactors(1500)
[1] 2 2 3 5 5 5
primeFactors(1521)
[1] 3 3 13 13
primeFactors(36254761235)
[1] 5 7 11 113 833347
primeFactors(25896321)
[1] 3 3 3 11 17 23 223
primeFactors(25821469)
[1] 25821469
primeFactors(36952147)
[1] 2447 15101
primeFactors(23621576)
[1] 2 2 2 11 41 6547
primeFactors(6985314)
[1] 2 3 3 7 55439
primeFactors(87452)
[1] 2 2 21863
primeFactors(326987125)
[1] 5 5 5 2615897
primeFactors(36582314)
[1] 2 18291157
primeFactors(96325741)
[1] 131 735311
primeFactors(121)
[1] 11 11
primeFactors(109)
[1] 109
primeFactors(136)
[1] 2 2 2 17
primeFactors(136672)
[1] 2 2 2 2 2 4271
primeFactors(137)
[1] 137
primeFactors(368742)
[1] 2 3 11 37 151
primeFactors(36)
[1] 2 2 3 3
primeFactors(49)
[1] 7 7
primeFactors(80)
[1] 2 2 2 2 5
primeFactors(23687111)
[1] 7 1297 2609
primeFactors(11111)
[1] 41 271
primeFactors(22222222)
[1] 2 11 73 101 137