The Kattis problem on this link asks to count the number of non-prime factors of an integer by respecting certain conditions. I did the following using Python: def NPF(): Q = int(input("number of queries (>= 1 and <= 3*10^6): ")) if 1 <= Q <= 3*(10**6): for q in range(Q): i = int(input("integer (>= 2 and <= 2*10^6): ")) if i == 2 or i == 3: return 1 if 4 <= i <= 2*(10**6): NPFL = [1] import math for j in range(4, math.floor(i/2) + 1): if i % j == 0: for k in range(2, math.floor(j/2) + 1): if j % k == 0: NPFL.append(j) break return len(NPFL) return 1 By typing NPF() on the IDLE and giving Q and i, it will count the number of non-prime factors. But I'm not sure how I can modify my code to fulfill all the requirements. Continue reading...