It\'s okay if anyone does not know about Scheme. I justneed some help on the alg
ID: 3616938 • Letter: I
Question
It's okay if anyone does not know about Scheme. I justneed some help on the algorithm regarding the number series of thepower of three. =)Write a procedure (power-of-3 x) that returns false if x is not apower of three and returns log_3 x otherwise. Assume that onlypositive integers will be passed to this procedure, and do not useany built in procedures other than basic arithmetic (+,*,-,/).
Hints: Use Iteration
Note: 0 is not a power of 3. The smallest integer power of 3 is 1,as 3^0 = 1. Does anyone know how to deal with this question? I havealready tried it but I was stuck in the middle. (define (power-of-3x)
(define (helper counter x)
(if (< x 0)
0
(cond (or (= x 1)
(= x 3)
(= (/ x 3) 0) I think the problem requires to check if the positive integersare 1, 3, 9, 27, 81 and so on. But I have no idea on how to checkthe succeeding numbers after '1' and '3'. It's okay if anyone does not know about Scheme. I justneed some help on the algorithm regarding the number series of thepower of three. =)
Write a procedure (power-of-3 x) that returns false if x is not apower of three and returns log_3 x otherwise. Assume that onlypositive integers will be passed to this procedure, and do not useany built in procedures other than basic arithmetic (+,*,-,/).
Hints: Use Iteration
Note: 0 is not a power of 3. The smallest integer power of 3 is 1,as 3^0 = 1. Does anyone know how to deal with this question? I havealready tried it but I was stuck in the middle. (define (power-of-3x)
(define (helper counter x)
(if (< x 0)
0
(cond (or (= x 1)
(= x 3)
(= (/ x 3) 0) I think the problem requires to check if the positive integersare 1, 3, 9, 27, 81 and so on. But I have no idea on how to checkthe succeeding numbers after '1' and '3'.
Explanation / Answer
Assuming that it returns trueif x is a power of 3 otherwise false (define (power-of-3 x) (cond ( (Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.