How long does it take to clear the debt (in months)?

Hello! I am new to R . Using a while loop I would need to answer this question. My loan is 1,000 euro, and has annual interest rate of 11%, compounded monthly. So, debt of d is d(1 + 0.11/12) after a month. My monthly repayments are 12 euro. How long does it take to clear the debt (shown in months)? Here is what I have so far. Also, how could I plot the amount I owned each month?

loan <- 1000
rate <- 0.11
target <- 0
nmonths <- 0
repayment <- 12

while(loan > target) {
......

A little more than 158 years.

library(FinancialMath)
i <- 0.11/12
p <- 1000
pay <- 12
amort.period(Loan = p,n = NA, pmt = pay,i = i,ic = 1,pf = 1,t = 1)
#>            Amortization
#> Loan        1000.000000
#> PMT           12.000000
#> Eff Rate       0.009167
#> Years        158.188204
#> At Time 1:     1.000000
#> Int Paid       9.166667
#> Princ Paid     2.833333
#> Balance      997.166667

loan <- 1000
monthlyrate <- 0.11/12
repayment <- 12
month <- 0
while(loan > 0){
month <- month + 1
interestpayment <- round(loan*monthlyrate,2)
loan <- loan - (repayment - interestpayment)
}
month - 1

I get 158 months.