Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

The compiler goes in segmentation fault with a fibonacci facuntion call (greater that 1)

$
0
0

my code is:

function fib(n::Integer)
    if n <= 1
        return n
    end
    
    return fib(n - 1) + fib(n + 2)
end

for i = 0:40
    println(fib(i))
end

and the output is:

0
1
[2]    5540 segmentation fault (core dumped)  julia fib.jl

why this?
it’s a fault of my code or of the compiler?
am I doing something wrong?

4 posts - 3 participants

Read full topic


Viewing all articles
Browse latest Browse all 2795

Trending Articles