Ameyo interview question

write the code for finding the nth term of Ap