Numbers that divide every cyclic permutation of their multiples
consider a number n
get all its 3 digit multiples, and cyclically permute them, so
123 -> 312 -> 231
test whether n divides all these
what n satisfies this condition ? answer given by following code
def cyc(zz):
return zz[-1]+zz[:-1]
def cyc2(a):
c=[a]
b=a
while a!=cyc(b):
c.append(cyc(b))
b=cyc(b)
return c
def mul(bb,n):
d=1
c=bb
p=[]
while len(str(c))<n+1:
c=bb*d
if len(str(c))==n:
p.append(c)
d+=1
return p
def cycdig(a,b):
z=[]
for ss in range(1,a):
tot=0
for y in mul(ss,b):
cou=0
for x in cyc2(str(y)):
if int(x)%ss==0:
cou+=1
if cou==len(cyc2(str(y))):
tot+=1
if tot==len(mul(ss,b)):
z.append(ss)
return z
print (cycdig(100,3))
the answers are 1,3,9,27,37