need help to solve a problem in scheme that we have to call a procedure "enequa" that we gave a real number n and it calculate the product of the first n odd numbers if we gave it a number bellow 1 it gave us 1....
exemples :
(enequa 5) = 1x3x5x7x9 = 945
(enequa 1) = 1
(enequa -2) = 1
should start
(define (enequa n)
i need help because i have o know answer to this problem after my mondy test
help in need
Re: help in need
You should've thought of it by yourself, it's pretty easy:
Code: Select all
(define (enequa n)
(if (< n 1)
1
(* (if (odd? n) n 1)
(enequa (- n 1)))))
cl-2dsyntax is my attempt to create a Python-like reader. My mirror of CLHS (and the dark themed version). Temporary mirrors of aferomentioned: CLHS and a dark version.
Re: help in need
Yes...but we cant use "odd?". And I already solve that problem.
Now I have another doubt.
I have a bit of difficulty making those tables for iterative processes and needed help to make one for this problem:
Consider a procedure called "adder" that when we give a natural n ir returns the sum of all odd natural smaller than n if n is even and the sum of all natural pairs smaller than n where n is odd.
Sry for my english
Now I have another doubt.
I have a bit of difficulty making those tables for iterative processes and needed help to make one for this problem:
Consider a procedure called "adder" that when we give a natural n ir returns the sum of all odd natural smaller than n if n is even and the sum of all natural pairs smaller than n where n is odd.
Sry for my english