Ch 03 Test 2022-10a
Based on 2020-2021 CCML 1 Freshmen contest.
-
(
opint
) Given integers m and n, find the number of ordered pairs of natural numbers $(a,b)$ with $1\le a \le m$ and $1 \le b \le n$, so that $a/b$ is a natural number. -
(
countdiv
) Count the number of divisors of a given number. -
Write a function to determine whether or not a number is prime.
isPrime :: Int -> Boolean isPrime n = False -- FIXME check_prime = [ isPrime 7, not (isPrime 9), isPrime 137, not (isPrime 91), isPrime 1231, not (isPrime 58483)]
-
(
lpd
) Determine the largest prime divisor of a number. If asked to find the largest prime divisor of 1 or 0, your function should give a message witherror
.lpd :: Int -> Int lpd n = 0 check_lpd = [7 == lpd 210, 251 == lpd 58483 ]
-
(
fromDigits
) Take a list of digits and produce a base ten number. Example: the list [1,6,5] should produce the number 165. -
How many four digit numbers consisting only of digits 1, 2, or 3 are divisible by 3? Make a list of them.
-
Lockers are numbered consecutively beginning with one. If the digit three is used exactly 114 times, determine the largest locker number that could be used.
Example: using exactly five threes, you can count to 31, so
locker 5 == 31
. The list with the 3’s in bold is: 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31.Another example:
locker 8 == 33
because the next two numbers (32 and 33) contain three more 3s.Advanced: expand your work for problem 7 into a function that takes in the number of threes you are looking for (like 114) and puts out the largest locker number that can be used.