Results 1 to 2 of 2

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

  1. #1
    Newbie
    Joined
    May 2012
    From
    England
    Posts
    1

    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
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Newbie
    Joined
    Aug 2012
    From
    USA
    Posts
    10

    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
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Josephus problem with varying k
    Posted in the Algebra Forum
    Replies: 1
    Last Post: January 14th 2012, 09:19 AM
  2. Replies: 24
    Last Post: June 26th 2011, 08:12 AM
  3. Josephus Problem
    Posted in the Algebra Forum
    Replies: 10
    Last Post: September 1st 2010, 10:06 AM
  4. A general case of polynomial long division?
    Posted in the Pre-Calculus Forum
    Replies: 2
    Last Post: August 30th 2010, 04:58 PM
  5. Is there a method for finding the general solution in this case?
    Posted in the Differential Equations Forum
    Replies: 6
    Last Post: August 13th 2009, 01:59 AM

Search Tags


/mathhelpforum @mathhelpforum