# Help with Project Euler #2: undef inits, printing, multiplication by juxtaposition, and more

**URL:** <https://discourse.julialang.org/t/help-with-project-euler-2-undef-inits-printing-multiplication-by-juxtaposition-and-more/106930>\
**Category:** New to Julia\
**Tags:** any\
**Created:** [November 30, 2023, 7:10am UTC](https://discourse.julialang.org/t/help-with-project-euler-2-undef-inits-printing-multiplication-by-juxtaposition-and-more/106930 "2023-11-30T07:10:07Z")\
**Posts on this page:** 3\
**Page:** 2

<div class="post-metadata">

**Author:** ![chandra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chandra/32/207807_2.png) [@chandra](https://discourse.julialang.org/u/chandra)\
**Post date:** [December 1, 2023, 6:22pm UTC](https://discourse.julialang.org/t/help-with-project-euler-2-undef-inits-printing-multiplication-by-juxtaposition-and-more/106930/22 "2023-12-01T18:22:25Z")

</div>

I am sorry but I do not see an edit icon at the top of the thread near my first post.

---

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [December 1, 2023, 6:44pm UTC](https://discourse.julialang.org/t/help-with-project-euler-2-undef-inits-printing-multiplication-by-juxtaposition-and-more/106930/23 "2023-12-01T18:44:36Z")

</div>

Ah, maybe it’s one of the options only unlocked with more time spent on the forum, my mistake. Seems like someone else with the option has chipped in already, though.

---

<div class="post-metadata">

**Author:** ![Dan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dan/32/42581_2.png) [@Dan](https://discourse.julialang.org/u/Dan)\
**Post date:** [December 1, 2023, 8:06pm UTC](https://discourse.julialang.org/t/help-with-project-euler-2-undef-inits-printing-multiplication-by-juxtaposition-and-more/106930/24 "2023-12-01T20:06:57Z")

</div>

Just for completeness, this is the version which uses Fibonacci formula to obtain closed form for this question (and it’s naturally faster):

```julia
sum_even_fib_limit = let α = inv(√5), φ = 0.5(1+√5), φ₋ = (1-φ), 
                         φ³ = φ^3, φ₋³ = φ₋^3
    (limit) -> begin
        n = floor(Int, log(limit/α)/log(φ)/3)
        return round(Int, 
          α*((φ³^(n+1)-1)/(φ³-1)-(φ₋³^(n+1)-1)/(φ₋³-1))
        )
    end
end;

```

For the limit in the thread:

```julia
julia> @btime sum_even_fib_limit(4e6)
  29.395 ns (1 allocation: 16 bytes)
4613732

```

WARNING label: This method may be limited by number representation inaccuracy in floating points.

[Previous page](https://discourse.julialang.org/t/help-with-project-euler-2-undef-inits-printing-multiplication-by-juxtaposition-and-more/106930.md?page=1)
