Well I made alot of try and this is the formula I came up with

if(rank >= 11, n - r + 1, switch(rank, 1, n - r + 29, 2, n - r + 20, 3, n - r + 14, 4, n - r + 10, 5, n - r + 8, 6, n - r + 6, 7, n - r + 5, 8, n - r + 4, 9, n - r + 3, 10, n - r + 2,))

I'm sure its too long for nothing but it works!