Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
|
|
@ -1,5 +1,5 @@
|
|||
using Memoize
|
||||
@memoize josephus(n::Integer, k::Integer, m::Integer=1) = n == m ? collect(0:m .- 1) : mod.(josephus(n - 1, k, m) + k, n)
|
||||
using Memoization
|
||||
@memoize josephus(n::Integer, k::Integer, m::Integer=1) = n == m ? collect(0:m .- 1) : mod.(josephus(n - 1, k, m) .+ k, n)
|
||||
|
||||
@show josephus(41, 3)
|
||||
@show josephus(41, 3, 5)
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
function josephus(n::Integer, k::Integer, m::Integer=1)
|
||||
p, i, seq = collect(0:n-1), 0, Vector{typeof(n)}(0)
|
||||
function josephus(n::T, k::T, m::T=one(T)) where T <: Integer
|
||||
p, i, seq = collect(0:n-1), 0, [zero(T)]
|
||||
while length(p) > m
|
||||
i = (i + k - 1) % length(p)
|
||||
push!(seq, splice!(p, i + 1))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue