def prime_factors(n): i = 2 while(i * i <= n): while(n % i == 0): yield i n //= i i += 1 if(n > 1): yield n # if you have sympy installed use this instead of # the prime_factors function defined above # from sympy.ntheory import factorint as prime_factors def gpf(n): return max(prime_factors(n),default=1) def a126289(n): return 1 if n == 1 else (n // gpf(n)) * gpf(n-1) def in_a337612(n): outputs = set() result = a126289(n) while(result not in outputs): outputs.add(result) result = a126289(result) return n in outputs i = j = 0 while(j < 200): i += 1 if(in_a337612(i)): j += 1 print(str(j) + " " + str(i))