About simple recursion code
Mostrar comentarios más antiguos
this code isn't work with me. for example i want to calculate the odd number in 9 is 5 odd number
function d = oddn(n)
%this program calculate the odd numbers in a number
if n==0 | mod(n,2)==0
d=0
elseif mod(n,2)~=0
d=1
else
d=oddn(n-1)+oddn(mod(n,2))
end
2 comentarios
KALYAN ACHARJYA
el 1 de Dic. de 2019
Editada: KALYAN ACHARJYA
el 1 de Dic. de 2019
"i want to calculate the odd number in 9 is 5 odd number"?
Can you clarify again?
Shahad Alsabi
el 1 de Dic. de 2019
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Logical en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!