Josephus Command

Can someone make a command to evaluate the answer to the Josephus Problem? If you don’t know what the Josephus problem is I’d recommend going to these two links. ( (
It should work like this.
!josephus 41 2 (or any other numbers other than 1 or 0)
Response: 19
Thanks in advanced :slight_smile:

This command uses the function given by Wikipedia:

!addcom !josephus $(eval g=(n,k)=>n==1?0:(g(n-1,k)+k)%n;m=decodeURIComponent("$(querystring)").match(/^(\d+) (\d+)$/);(m&&(n=parseInt(m[1]))>1&&(k=parseInt(m[2]))>1)?g(n,k)+1:"Use this command to solve the Josephus problem. Enter the number of people in the initial circle followed by the count for each step. For example, !josephus 41 2")
1 Like

Thanks you so much! It works perfectly. :slight_smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.