finding nth value of formula with conditions

hello,
can u guys please help me finding nth value by using the next formula:
a(0)=2
a(1)=3
a(n)=(1-a(n-1))/a(n-1) +a(n-2)
thanks!

Answers (1)

KSSV
KSSV on 1 May 2020
Edited: KSSV on 1 May 2020
n = 10 ; % size of the array
a = zeros(n,1) ; % Initialize the array
a(1)=2 ; % value at n = 1
a(2)=3 ; % value at n = 2
% loop to get each value
for i = 3:n
a(i)=(1-a(i-1))/a(i-1) +a(i-2) ; % the formula you have given
end

2 Comments

thanks a lot , can u please teach how you did that?
I have commented the steps......thanks is accepting the asnwer. :)

Sign in to comment.

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Asked:

on 1 May 2020

Commented:

on 1 May 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!