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

Other questions on the subject: Engineering

image
Engineering, 04.07.2019 18:10, jadeochoa4466
The temperature of air decreases as it is compressed by an adiabatic compressor. a)- true b)- false
Answers: 2
image
Engineering, 04.07.2019 18:10, siri5645
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
image
Engineering, 04.07.2019 18:10, Tyrant4life
Draw the engineering stress-strain curve for (a) bcc; (b) fcc metals and mark important points.
Answers: 1
image
Engineering, 04.07.2019 18:10, katelynn73
Atmospheric air has a temperature (dry bulb) of 80° f and a wet bulb temperature of 60° f when the barometric pressure is 14.696 psia. determine the specific humidity, grains/lb dry air. a. 11.4 c. 55.8 d. 22.5 b. 44.1
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 in other subjects:

Konu
Mathematics, 24.05.2020 11:57
Konu
Mathematics, 24.05.2020 11:57