Josephus problem variation and it's output (general case)

Hello,

Background: this is my way of gently easing myself back into the study of maths and cs, specifically functional programming (this a hobby and not homework). I chose Excel after learning that spreadsheets are sometimes described as being primitive FP and wanted the challenge of using only worksheet functions to solve various problems as a precursor to learning a FP language such as Haskell.

Problem: I'm trying to model a counting out problem within MS Excel and seek help on the maths please.

I want to be able to produce a table/grid showing all the eliminations and I want to do this in two ways and for any size circle/list and count:

1. e.g. list=8, count =5 (begin with 1)

col1=1-8

col2=1,2,3,4,BLANK,6,7,8

col3=1,BLANK,3,4,BLANK,6,7,8

etc.

2. this time contract the list

col1=1-8

col2=1,2,3,4,6,7,8

col3=1,3,4,6,7,8

etc.

I have looked at the maths for the Josephus problem (going direct to the "last man standing") found for instance on Wikipedia, but am struggling to modify/adapt this to produce the output of each elimination. I need an introduction to solving this type of problem please. Intuitively I see the use of mod and clock arithmetic but have so far failed to come up with the goods

TIA, Ian

Re: Josephus problem variation and it's output (general case)

Write a function that takes two positive integers n and k as arguments and returns the number of the last person remaining out of n after counting out each k-th person.

This is a code-golf challenge, so the shortest code wins.

__________________________

Even Giants Born Small

Free neuropathy remedy