Question: IN SCHEME PROGRAMMING LANGUAGE (Racket) Write a procedure random-k-digit-number that takes an integer k > 0 and returns a random k-digit number. You should choose

IN SCHEME PROGRAMMING LANGUAGE (Racket) Write a procedure random-k-digit-number that takes an integer k > 0 and returns a random k-digit number. You should choose each digit using the built-in procedure random, then construct the k-digit number by putting those digits together. For example, if you generate two digits a and b, then you can form a two-digit number by computing 10a + b.

(define random-k-digit-number

(lambda (n)

your-answer-here

))

Test your procedure on at least the following test cases:

(random-k-digit-number 1) ; -> ? (1 digit) (random-k-digit-number 3) ; -> ??? (1-3 digits) (random-k-digit-number 3) ; -> ??? (is it different?) (random-k-digit-number 50) ; -> ???... (1-50 digits)

Note that random-k-digit-number may return a number shorter than k digits, since the leading digits of the number may turn out to be 0. The result will be a random number in the range [0, 10k 1].

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!