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 12:10
On a average work day more than work place firs are reorted
Answers: 1
question
Engineering, 04.07.2019 18:10
The mass flow rate of the fluid remains constant in all steady flow process. a)- true b)- false
Answers: 1
question
Engineering, 04.07.2019 18:10
The filament of an incandescent lamp has a temperature of 2000k. calculate the fraction of radiation emitted in the visible light band if the filament is approximated as blackbody
Answers: 2
question
Engineering, 04.07.2019 18:10
Calculate the bore of a cylinder that has a stroke of 18 inches and an extension time of 6 seconds at a flow rate of 4 gal/min.
Answers: 3
You know the right answer?
Complete the recursive function to determine if a number is prime. skeletal code is provided in the...
Questions
question
Geography, 26.08.2019 20:30
question
Mathematics, 26.08.2019 20:30
Questions on the website: 13722367