About simple recursion code
显示 更早的评论
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 个评论
KALYAN ACHARJYA
2019-12-1
编辑:KALYAN ACHARJYA
2019-12-1
"i want to calculate the odd number in 9 is 5 odd number"?
Can you clarify again?
Shahad Alsabi
2019-12-1
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!