简体   繁体   中英

How do you make sense of this coding question?

I have been given a coding question to answer, however I'm unable to make sense of it:

Consider a sequence of integers A1, A2, ... for which An = A(n-1) + A(n-2) for all n > 2. You are given the first two elements of the sequence A1 and A2, and the index n. Write a function to output the n-th element of the sequence. The function will take a single argument consisting of a single string which contains integers A1, A2 and n separated by single spaces.

While I'm not looking for anyone to give me the answer, could anyone break this down or explain it to me as a starting point?

Many Thanks

I think that what they mean is that n is the value of A in the array. For example, say you are trying to find A1, I would say in this case n=1 and therefore plugging in the equation that would be A1=A(1-1) + A(1-2). This is a very confusing equation and I hope my answer helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM