loading...

re: Challenge: find 'Kaprekar numbers' VIEW POST

FULL DISCUSSION
 

Something like this in python

from itertools import count

def kaprekar_generator(n):
    c=0
    for x in count(1):
        x2 = str(x**2)
        if int(x2[:int(len(x2)/2)] if len(x2) > 1 else 0) + int(x2[int(len(x2)/2):]) == x:
            yield x
            c+=1
            if c >= n: break

print([x for x in kaprekar_generator(8)])
Code of Conduct Report abuse