Skip to content

Instantly share code, notes, and snippets.

@p1scescom
Last active December 17, 2018 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save p1scescom/6ed2964fa2aa3fd8fc49c90e55a8d2dc to your computer and use it in GitHub Desktop.
Save p1scescom/6ed2964fa2aa3fd8fc49c90e55a8d2dc to your computer and use it in GitHub Desktop.
tak julia script ver
module M
global c = 0
function tak(x::Int,y::Int,z::Int)::Int
global c += 1
if x <= y
y
else tak(tak(x-1,y,z), tak(y-1,z,x), tak(z-1,x,y))
end
end
function julia_main()
t = tak(12,6,0)
println("tak(12,6,0) = $t")
println("c = $c")
return 0
end
julia_main()
end
module M
global c = 0
function tak(x::Int,y::Int,z::Int)::Int
global c += 1
if x <= y
y
else tak(tak(x-1,y,z), tak(y-1,z,x), tak(z-1,x,y))
end
end
Base.@ccallable function julia_main(ARGS::Vector{String})::Cint
t = tak(12,6,0)
println("tak(12,6,0) = $t")
println("c = $c")
return 0
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment