(11C) n-th term of a Geometric Sequence
|
05-21-2018, 12:47 PM
(This post was last modified: 05-21-2018 01:31 PM by Dieter.)
Post: #2
|
|||
|
|||
RE: (11C) n-th term of a Geometric Sequence
(05-21-2018 09:31 AM)Gamo Wrote: Formula: a sub n = ar^n-1 for every integer n ≥ 1 an = a1 · rn–1 (05-21-2018 09:31 AM)Gamo Wrote: Gamo, all these tests and subroutines are not required. You do not have to check whether r is negative or not, and if it is, also check if n is odd or even. All HP calculators I know can calculate integer powers of negative bases directly. So (–3,14)5 directly yields –305,24... without any problem. This means the more than 40 steps routine at LBL D can be replaced with this: Code: LBL D That's it. If you really want to check for odd or even n and whether r is negative or not, you could do it much shorter. Simply calculate the power with |r| and change the sign if r<0 and n is even. For instance this way: Code: LBL D But again: all this is not required. You know I'm a big fan of using the stack instead of registers, so here's how I would do it: Code: LBL A The ENTER in the second line usually is not required, but this way the program will also run on an HP25. ;-) Usage: a1 [ENTER] r [ENTER] n [A] => an [x] => an+1 [x] => an+2 ... Example: 1 [ENTER] –3 [ENTER] 1 [A] 1 [x] –3 [x] 9 [x] –27 [x] 81 [x] –243 ... Dieter |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
(11C) n-th term of a Geometric Sequence - Gamo - 05-21-2018, 09:31 AM
RE: (11C) n-th term of a Geometric Sequence - Dieter - 05-21-2018 12:47 PM
RE: (11C) n-th term of a Geometric Sequence - Gamo - 05-21-2018, 03:42 PM
RE: (11C) n-th term of a Geometric Sequence - Dieter - 05-21-2018, 04:06 PM
|
User(s) browsing this thread: 1 Guest(s)