Hopfstader's functions are defined as below. Can we find a pattern? From a Tweet [insert link]
using PyPlot
F(n) = n==0 ? 0 : n - F(n-1)
G(n) = n==0 ? 0 : n - G(G(n-1))
H(n) = n==0 ? 0 : n - H(H(H(n-1)))
H (generic function with 1 method)
x = 0:120
#f = [F(n) - F(n-1) for n in x]
#g = [G(n) - G(n-1) for n in x]
@time h = [n==0 ? 0 : n - h[h[h[n]]] for n in x]
#plot(x,h,hs)
BoundsError: attempt to access 121-element Array{Int64,1} at index [0] Stacktrace: [1] getindex(::Array{Int64,1}, ::Int64) at ./array.jl:729 [2] (::getfield(Main, Symbol("##11#12")))(::Int64) at ./none:0 [3] iterate at ./generator.jl:47 [inlined] [4] collect_to!(::Array{Int64,1}, ::Base.Generator{UnitRange{Int64},getfield(Main, Symbol("##11#12"))}, ::Int64, ::Int64) at ./array.jl:651 [5] collect_to_with_first!(::Array{Int64,1}, ::Int64, ::Base.Generator{UnitRange{Int64},getfield(Main, Symbol("##11#12"))}, ::Int64) at ./array.jl:630 [6] collect(::Base.Generator{UnitRange{Int64},getfield(Main, Symbol("##11#12"))}) at ./array.jl:611 [7] top-level scope at util.jl:156 [8] top-level scope at In[11]:2
for i in 1:50
for k in 1:200 - i
if h[i] != h[i+k]
print("Not ", i)
break
end
end
end