Question: This is the code that I currently have. I am unsure on how to do part C or if I even did the first two
This is the code that I currently have. I am unsure on how to do part C or if I even did the first two correctly. Any help would be great!
(define (H n) (cond ((= n 0) 1) ((+ (H (- n 1))) (* 2 (P (- n 1))))))
(define (P n) (cond ((= n 0) 0) ((+ (H (- n 1))) (P (- n 1))))) (define (t n) (cond ((equal? n 0) 1) ((even? n) (* 2 (expt P 2))) ((expt H 2))))


4. The half-companion Pell numbers H, and the Pell numbers Pn can be defined by the following paired recurrence relations. Notice H, is defined in terms of both H, and Pn. So is Pre i if n=0 Hn= ..+2P-1 otherwise o if n=0 " H,-1+Pn-1 otherwise (a) Provide a SCHEME function, named (H n) which takes one parameter, n, and returns the half-companion Pell number at index n using the recurrence relation above. (b) Provide a SCHEME function, named (Pn) which takes one parameter, n, and returns the Pell number at index n using the recurrence relation above. 00 0000 0000 00000 0000000 00000000 000000 COCO OOO000 OOO000 00000 OOOOOO Figure 1: 36 circles arranged in a triangle as well as a square. A triangular number counts objects arranged in an equilateral triangle. The nth triangular number is the number of objects arranged in an equilateral triangle with n items along each side. A square triangular number is a triangular number that is also a perfect square. The problem of finding square triangular numbers reduces to Pell's equation in that every triangular number is of the form (0+1). Therefore we seek integers t and s such that "* = sa. (c) Define a SCHEME function named (t n) to compute the t value for the nth triangular square. Use the following definition to write your function: 2P2 if n is even tn = 142 if n is odd 4. The half-companion Pell numbers H, and the Pell numbers Pn can be defined by the following paired recurrence relations. Notice H, is defined in terms of both H, and Pn. So is Pre i if n=0 Hn= ..+2P-1 otherwise o if n=0 " H,-1+Pn-1 otherwise (a) Provide a SCHEME function, named (H n) which takes one parameter, n, and returns the half-companion Pell number at index n using the recurrence relation above. (b) Provide a SCHEME function, named (Pn) which takes one parameter, n, and returns the Pell number at index n using the recurrence relation above. 00 0000 0000 00000 0000000 00000000 000000 COCO OOO000 OOO000 00000 OOOOOO Figure 1: 36 circles arranged in a triangle as well as a square. A triangular number counts objects arranged in an equilateral triangle. The nth triangular number is the number of objects arranged in an equilateral triangle with n items along each side. A square triangular number is a triangular number that is also a perfect square. The problem of finding square triangular numbers reduces to Pell's equation in that every triangular number is of the form (0+1). Therefore we seek integers t and s such that "* = sa. (c) Define a SCHEME function named (t n) to compute the t value for the nth triangular square. Use the following definition to write your function: 2P2 if n is even tn = 142 if n is odd
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
