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
Explain the difference laminar and turbulent flow. explain it with the shear stress and the velocity profiles.
Answers: 1
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
Compute the pressure drop of 30°c air flowing with a mean velocity of 8 m/s in a circular sheet-metal duct 300 mm in diameter and 15 m long. use a friction factor, f 0.02, and pair = 1.1644 kg/m a. 37.26 pa b. 25.27 pa n c. 29.34 pa d. 30.52 pa
Answers: 1
question
Engineering, 04.07.2019 18:20
Ahe-xe mixture containing a 0.75 mole fraction of helium is used for cooling electronics in an avionics application. at a temperature of 300 k and atmospheric pressure, calculate the mass fraction of helium and the mass density, molar concentration and molecular weight of the mixture. if the cooling capacity is 10 l, what is the mass of the coolant?
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
English, 20.04.2020 21:46
question
Chemistry, 20.04.2020 21:49
question
Mathematics, 20.04.2020 21:50
Questions on the website: 13722367