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, 03.07.2019 14:10
Amass of 1.5 kg of air at 120 kpa and 24°c is contained in a gas-tight, frictionless piston-cylinder device. the air is now compressed to a final pressure of 720 kpa. during the process, heat is transferred from the air such that the temperature inside the cylinder remains constant. calculate the boundary work input during this process.
Answers: 2
question
Engineering, 04.07.2019 18:10
Refrigerant 134a enters an insulated compressor operating at steady state as saturated vapor at -26°c with a volumetric flow rate of 0.18 m3/s. refrigerant exits at 9 bar, 70°c. changes in kinetic and potential energy from inlet to exit can be ignored. determine the volumetric flow rate at the exit, in m3/s, and the compressor power, in kw.
Answers: 1
question
Engineering, 04.07.2019 18:10
At 12 noon, the count in a bacteria culture was 400; at 4: 00 pm the count was 1200 let p(t) denote the bacteria cou population growth law. find: (a) an expression for the bacteria count at any time t (b) the bacteria count at 10 am. (c) the time required for the bacteria count to reach 1800.
Answers: 1
question
Engineering, 04.07.2019 18:10
Which of the following components of a pid controlled accumulates the error over time and responds to system error after the error has been accumulated? a)- proportional b)- derivative c)- integral d)- on/off.
Answers: 2
You know the right answer?
Complete the recursive function to determine if a number is prime. skeletal code is provided in the...
Questions
question
English, 06.07.2019 21:00
Questions on the website: 13722361