How do I write a pseudocode to calculate the nth term of an arithmetic series with a difference of b and the first term?

Viewed 24

please don't use formula Un = a + (n-1)b, use looping

I tried to figure this out but i cannot find how to create pseudocode looping without formula

1 Answers

Given a and b, you can loop n-1 times and add b to the result.

In pseudocode:

u = a;
Loop n-1 times: // Note that if n=1, n-1 is 0, and the loop won't happen
   u += b
Related