We need to create a program that outputs the number of abbreviations and prime numbers of integers from 2 to n by receiving more than 2 integers, but it gets blocked at the output part.
def readNumber():
while True:
n = int (input ("Enter an integer")
if (n >= 2):
break
else:
print("Please enter a number greater than or equal to 2.")
continue
return n
def getCountsOfDivisors(n):
count = 0
for i in range(1, n+1):
if n % i == 0:
count += 1
return count
def isPrime(n):
for f in range(2, n-1):
if n % f == 0:
return False
else:
return True
num = readNumber()
for t in range (2, num + 1):
print("integer:" + str(t) +"minimal number:" + str(getCountsOfDivisors(t)) +"minority:" + str(isPrime(t))))
I made the chords like this In the output, the decimal function value appears as None when integers are 2 or 3.
May I know what the problem is?
In range (2, n-1), n-1 becomes a lower number than 0 if n is 2 or 3.
To activate the for statement, n-1 should be greater than 2, at least 3, but it doesn't.
586 Uncaught (inpromise) Error on Electron: An object could not be cloned
571 PHP ssh2_scp_send fails to send files as intended
563 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
857 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.