擅长:python、mysql、java
<p>这里是更干净的版本;
a) 已删除函数输出的打印,因为未返回任何输出
b) 跟踪primeDict(字典)中的所有素数</p>
<pre><code>def primes_number(number = 5):
primesDict = {}
for x in range(1, number):
for y in range(2, x):
if((number % x) != 0):
if y in primesDict : continue
primesDict[y] = x
print(y)
print(primes_number(number=7))
</code></pre>
<p>输出</p>
<pre><code>2
3
4
5
</code></pre>