Question: You may not use any external libraries to solve these problems. 1. Goldbach's conjecture says that every positive even number greater than 2 is the
You may not use any external libraries to solve these problems.
1. Goldbach's conjecture says that every positive even number greater than 2 is the sum of two prime numbers. Write an SML function goldbach that takes a single positive, even integer as its parameter and returns a list containing the two prime numbers that sum to the parameter. You may assume that the parameter is a positive, even integer. Examples:
goldbach(4000) would return [11, 3989] or [3989, 11]
goldbach(3818) would return [79, 3739] or [3739, 79]
2. A bitwise AND takes two equal-length binary representations and performs the logical AND operation on each pair of the corresponding bits. Thus, if both bits in the compared position are 1, the bit in the resulting binary representation is 1. Otherwise, the result is 0. For example the bitwise AND of 10110 and 10011 is 10010. Write an SML function bitwise_and that takes two integers as parameters and returns the 8-bit bitwise AND of the two integers' binary representations as a list of 1s and 0s. You may assume that both parameters are in the range 0 through 255, inclusive. Examples:
bitwise_and(31, 12) would return [0,0,0,0,1,1,0,0]
bitwise_and(45, 172) would return [0,0,1,0,1,1,0,0]
bitwise_and(65, 255) would return [0,1,0,0,0,0,0,1]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
