# Help with speeding up this code

**URL:** <https://discourse.julialang.org/t/help-with-speeding-up-this-code/101407>\
**Category:** Performance\
**Created:** [July 9, 2023, 5:17pm UTC](https://discourse.julialang.org/t/help-with-speeding-up-this-code/101407 "2023-07-09T17:17:16Z")\
**Posts on this page:** 1\
**Showing post:** 22

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [July 9, 2023, 11:17pm UTC](https://discourse.julialang.org/t/help-with-speeding-up-this-code/101407/22 "2023-07-09T23:17:35Z")

</div>

> [@Mark\_Szlazak](#):
>
> ```julia
> if k == 1 || n == 0
> return 1.0
> end
> 
> ```

My generic advice here is that if you want recursion to be fast (in any language), you should ideally enlarge the base case (“coarsen” the recursion) — see [this comment](https://discourse.julialang.org/t/recursive-call-vs-while-loop/7723/18).

(That being said, maybe with memo-ization here you won’t call the trivial base cases enough to matter?)

---

_[View the full topic](https://discourse.julialang.org/t/help-with-speeding-up-this-code/101407)._
