# Write while loop equivalent in elixir

**URL:** <https://forum.elixirforum.com/t/write-while-loop-equivalent-in-elixir/15880>\
**Category:** Questions\
**Tags:** while, loop\
**Created:** [August 16, 2018, 11:03am UTC](https://forum.elixirforum.com/t/write-while-loop-equivalent-in-elixir/15880 "2018-08-16T11:03:27Z")\
**Posts on this page:** 1\
**Showing post:** 23

<div class="post-metadata">

**Author:** ![flashup4all](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/flashup4all/32/18825_2.png) [@flashup4all](https://forum.elixirforum.com/u/flashup4all)\
**Post date:** [February 12, 2020, 12:58pm UTC](https://forum.elixirforum.com/t/write-while-loop-equivalent-in-elixir/15880/23 "2020-02-12T12:58:29Z")

</div>

```elixir
def interest_calculator(interest, amount, no_of_days) do
    interest_per_day = ((interest/100)/30) |> Float.floor(4) 
    amount_interest_per_day = interest_per_day * amount
    total_balance = amount_interest_per_day + amount
    case no_of_days > 0 do
      true -> calculator(interest, total_balance, no_of_days-1)
      false -> amount
    end
  end

```

---

_[View the full topic](https://forum.elixirforum.com/t/write-while-loop-equivalent-in-elixir/15880)._
