Josephus Survivor for General Step Size

Find the one-based survivor when counting begins at position one and every kth person is removed, using an exact decimal step size and at most 100,000 people.

Description

The Josephus problem removes every kth person around a circle until one remains.

The Josephus problem removes every kth person around a circle until one remains. Survivor numbering and the initial counting position are essential conventions.1

The tool returns survivor. The indexing and output conventions below determine how to read these values.

When to use Josephus Survivor for General Step Size

Use this for the following task: Find the one-based survivor when counting begins at position one and every kth person is removed, using an exact decimal step size and at most 100,000 people. Use the input and output conventions below to reproduce the intended mathematical quantity.

How to use Josephus Survivor for General Step Size and understand its results

  1. Choose the required indexes, integers or sequence entries. Preserve decimal-string encodings where the field table specifies strings.
  2. Enter people, step according to the field table, then run the tool.
  3. Read survivor. Use the stated units, indexing and interpretation of the numerical result.
  4. Keep exact decimal strings for subsequent integer arithmetic; distinguish them from any explicitly approximate numeric result.
Input fieldMeaningValue type and boundsRequirement
peoplePeople in the circle (resource limit 100000)integer; minimum 1; maximum 100000Required
stepPositive counting stepstring (integer/arbitrary); maximum text length 200; pattern ^[1-9][0-9]*$Required

Read the positive step as a BigInt decimal string and iterate circle sizes from two through the positive people count. Return a one-based survivor.

zero-based J(1,k)=0; J(n,k)=(J(n−1,k)+k) mod n; output=J+1

The symbols and boundary conditions refer to the supplied fields and the implementation described above.

Output fieldMeaningValue type
survivorOne-based survivor positioninteger
json
{
  "input": {
    "people": 7,
    "step": "3"
  },
  "output": {
    "survivor": 4
  }
}

Limitations and assumptions

Counting starts at position one, and the first removal is the kth count. At most 100000 people are accepted; no elimination-order list or alternative starting position is produced.

Use the declared integer bounds and string formats. Large exact outputs remain decimal strings; numerical approximations use ordinary floating-point arithmetic. A rejected input is different from a valid zero count or false membership flag.

Alternative or Complementary methods

Choose Linear Congruence Solver when you need its operation: Solve a·x≡b (mod m) exactly, returning a residue, solution period, and number of residues modulo m; unsatisfiable equations return zero certificate fields. Choose One Collatz 3n+1 Step for the complementary operation: Return one full Collatz step for a positive decimal integer: n/2 when even and 3n+1 when odd, including 1→4 and an input limit of 200 characters.

Background reference: The Josephus Problem.

References

  1. The Josephus Problem — Stony Brook University

Similar or alternative tools

  • Linear Congruence Solver

    Solve a·x≡b (mod m) exactly, returning a residue, solution period, and number of residues modulo m; unsatisfiable equations return zero certificate fields.

  • One Collatz 3n+1 Step

    Return one full Collatz step for a positive decimal integer: n/2 when even and 3n+1 when odd, including 1→4 and an input limit of 200 characters.

Don't forget to set a bookmark for tool.io!
Privacy | Imprint | Cookies