Skip to content

Instantly share code, notes, and snippets.

@sohanmanju
Created August 1, 2020 06:14
Show Gist options
  • Save sohanmanju/da8d3f0d22101bc858f48780f2f8978f to your computer and use it in GitHub Desktop.
Save sohanmanju/da8d3f0d22101bc858f48780f2f8978f to your computer and use it in GitHub Desktop.
import math
numbers = map(int, input("Please Enter any Numbers: ").split(","))
def isEqualFactors(N):
ev_count = 0
od_count = 0
for i in range(1, (int)(math.sqrt(N)) + 2):
if N % i == 0:
if i == N // i:
if i % 2 == 0:
ev_count += 1
else:
od_count += 1
else:
if i % 2 == 0:
ev_count += 1
else:
od_count += 1
if (N // i) % 2 == 0:
ev_count += 1
else:
od_count += 1
if ev_count == od_count:
return True
return False
def print_factors(x):
print("The factors of", x, "are:")
for i in range(1, x + 1):
if x % i == 0:
print(i)
for number in numbers:
if isEqualFactors(number):
print_factors(number)
print("Yes, it has equal number of odd and even factors and the product is good!")
else:
print(number)
print(" Nope, the product is not good")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment