from math import sqrt

N = 179
k = 7

def premiers(n):
  prem=list(range(2,n+1))
  k=2
  nRacine=sqrt(n)
  while k<nRacine:
    prem=[p for p in prem if p<=k or p%k!=0]
    k=prem[prem.index(k)+1]  # nouveau nombre premier
  return prem



table = [k+1 for k in range(N)]
prem = premiers(N+1)

ordre = list()
while len(table)>0:
    ordre.append(table[k%len(table)])
    table = table[k%len(table)+1:] + table[:k%len(table)]

for i in range(len(ordre)):
    if i+1 in prem:
        print(ordre[i], end=', ')
