跳转到主要内容
Calcton

Josephus Problem Calculator

Free online josephus problem calculator. Enter your values and get instant results with the formula, step-by-step working, a worked example and FAQs — everything runs locally in your browser on Calcton, no signup required.

中文版:约瑟夫问题幸存者计算器

Josephus Problem Calculator
人数 n(围成一圈)
报数步长 k(每数到第 k 个出列)

原理

约瑟夫问题源自弗拉维奥·约瑟夫斯的叙述:n 人围圈,从 1 号开始报数,每数到第 k 人出列,下一位重新报数,求最后幸存者。递推 J(1) = 0、J(i) = (J(i−1) + k) mod i(0 起始)一步 O(n) 得解;k = 2 时有闭式:写 n = 2^m + L,幸存者 = 2L + 1。

经典一问 n = 41、k = 2:41 = 32 + 9,幸存位置 2×9 + 1 = 19。传说约瑟夫斯与同伴靠此推理站到免死的 16、31 号(留最后两名的变体),而非唯一幸存位。

使用步骤

① 输入人数 n 与步长 k;② 得到幸存者编号与出列顺序前 8 位;③ k = 2 时可用 2L+1 口算验证。

计算示例

J(5, 2) = 3(出列 2、4、1、5,剩 3);J(41, 2) = 19;J(100, 3) = 91;J(1000, 7) = 404。

注意事项

编号约定影响答案:本工具用 1 起始、从 1 号开始报数;若从第 s 人开始报数,幸存者为 (J(n,k) + s − 1) mod n + 1。k = 1 时每轮第一人出列,幸存者是第 n 人。

常见问题

Q:为什么 k = 2 有公式?A:每淘汰一轮人数减半,2 的幂处编号重置为 1,此后每次淘汰跳一格——幸存者恰是「补到下一个 2 的幂所需的 2L 步」对应者。

Q:能求第 m 个出列者吗?A:可以,反向递推或用阶乘数系(k = n 的情形与排列秩一一对应),本工具给出前 8 个出列位供核对。

参考值区(同源数值校验)

J(41, 2) = 19(2L+1 = 19)、J(7, 3) = 4、J(1000, 7) = 404;出列顺序 n=5, k=2:2 → 4 → 1 → 5,幸存 3。

How to use the Josephus Problem Calculator

  1. Fill in the inputs with your own numbers — every field shows what it expects.
  2. The result updates instantly as you type; no "Calculate" click needed.
  3. Read the result card for the main figure, the step-by-step formula, and practical notes.

Frequently asked questions

Is the Josephus Problem Calculator free?

Yes — all math calculators on Calcton are free, with no sign-up required. Your inputs are processed in your browser and never sent to a server.

Is there a Chinese version of this tool?

Yes. Use the Chinese version link above — it is the same calculator with the interface in Simplified Chinese.

References

Formulas and benchmarks used by this calculator follow these published sources.

  1. dlmf.nist.gov
  2. mathworld.wolfram.com
Kevin's profile

KevinContent LeadCalcton Editorial Team · Last updated 2026-09-30

Kevin maintains Calcton's formula verification and content: every calculator cites the standard it implements, worked examples are recomputed programmatically, and health benchmarks follow WHO and international guidelines.

Related calculators

More in this category: Math calculators

About math calculators

Free online math calculators for algebra, statistics, number theory and everyday arithmetic — from quadratic equations and matrices to percentages, fractions and prime factorization, each with step-by-step formulas.

搜索计算器

搜索全站计算器、分类与页面,回车直达