1
isPrime
関数をそれ自身で実行しようとすると、n
を任意の整数に置き換えます。素数であるかどうか。しかし、a
とb
をprimes
から得ることが、それらが素数であるかどうかを調べるための数字の範囲として使用することが、問題のあるところです。引数としてaとbをローカル関数 "isPrimes"に渡して、範囲として使用しようとしています
def primes(a,b):
pass
def isPrime(n):
# I want to make n take the values of a and b so that the is Prime
# function executes all the prime numbers within the range a to b
if n == 1:
return False
# here I've tried referencing n and (a,b) as the range but neither
# option does anything
for z in range(a, b):
if n % z == 0:
return False
else:
# this is supposed to print the n each time it comes up as a prime
# number but when I run this nothing happens and I'm not sure where
# I'm going wrong
print(n)
return True