subject
Engineering, 04.09.2019 20:30 carcon2019

Complete the recursive function to determine if a number is prime. skeletal code is provided in the primechecker function.
complete the solution:
% usernum: value checked for prime
function isprime = checkvalue(usernum)
% do not modify, calls the recursive primechecker function
isprime = primechecker(usernum, usernum-1);
end
function primeresult = primechecker (testval, divval)
% complete the recursive function primechecker
% function returns 0 if testval is not prime and 1 if testval is prime
% test case 1: if testval is 0 or 1, assign primeresult with 0 (not prime)
primeresult = 0;
% test case 2: if testval is only divisible by 1 and itself,
% assign primeresult with 1 (is prime)
% hint: use divval
% test case 3: if testval can be evenly divided by divval,
% assign primeresult with 0 (not prime)
% hint: use the % operator
% otherwise, assign primeresult with the result of the recursive call
% to primechecker with testval and (divval - 1)
end

ansver
Answers: 3

Another question on Engineering

question
Engineering, 04.07.2019 08:10
Which of the following is an easy way to remember the modified “x” tire rotation? a. nondrive wheels straight, cross the drive wheels b. drive wheels straight, cross the nondrive wheels c. drive wheels crossed, nondrive wheels straight d. drive wheels crossed, nondrive wheels crossed
Answers: 1
question
Engineering, 04.07.2019 18:10
An air conditioning system consist of a 5 cm diameter pipe, operating at a pressure of 200 kpa. the air initially enters the pipe at 15°c with a velocity of 20 m/s and relative humidity of 80%. if the heat supply throughout the process is 960 w, determine the relative humidity and the temperature at the outlet
Answers: 3
question
Engineering, 04.07.2019 18:10
During a steady flow process, the change of energy with respect to time is zero. a)- true b)- false
Answers: 2
question
Engineering, 04.07.2019 18:10
Apipe with an outside diameter of 15 cm is exposed to an ambient air and surrounding temperature of -20°c. the pipe has an outer surface temperature of 65°c and an emissivity of 0.85. if the rate of heat loss from the pipe surface is 0.95 kw per meter of length, the external convective heat transfer coefficient (h) is: (a) 12.5 w/m"k (b) 18.6 w/mk (c) 23.7 w/mk (d) 27.9 w/mk (e) 33.5 w/mk
Answers: 1
You know the right answer?
Complete the recursive function to determine if a number is prime. skeletal code is provided in the...
Questions
question
Mathematics, 15.04.2021 19:40
question
Mathematics, 15.04.2021 19:40
question
Mathematics, 15.04.2021 19:40
question
Mathematics, 15.04.2021 19:40
question
Computers and Technology, 15.04.2021 19:40