@someone, true reminder is anything so difficult to prove, but definitely efficient.
For My approach I was just trying leaverage some other methods like Josephus Problem, but looks like it is not possible, so I want drop my approach.
Someone, I like your idea, better than n square so I upvoted it. However I was wondering if there are n such card which may be thousands to millions & for that case every time the reminder coming as divisor-1, which would lead to n^2 solution. So is there any way of we can take array of n number & place from 1 to n by doing some mathematical calculation which is constant time (just a thought not sure we can do this). like for first 3 numbers as below
initially idx = 0
for num =1, idx = (idx+num+1)%13 =2
for num = 2, idx = (idx+num+1)%13 = 5
for num = 3, idx = (idx+num+1)%13 = 9
after this things starting messed up. so is there way to find correct formula so that this can be done in O(N)
idx 1 2 3 4 5 6 7 8 9 10 11 12 13
pos x 1 x x 2 x x x 3 x x x x
wrong check these prime numbers with gap less than 6, 41 43 47 53 59 61 67 71- abcd July 23, 2014