统计学
All
Feeds
已回答
I want to write a recursive Function that can calculate the sum of all the digit. If the input is 12345 then the answer will be 1+2+3+4+5 , without using string2num and loop.
You can do this with any inbuit functions. function x = digit_sum(n) x=0; if n>0 x=mod(n,10)+digit_sum(floor(n./10));%...
I want to write a recursive Function that can calculate the sum of all the digit. If the input is 12345 then the answer will be 1+2+3+4+5 , without using string2num and loop.
You can do this with any inbuit functions. function x = digit_sum(n) x=0; if n>0 x=mod(n,10)+digit_sum(floor(n./10));%...
4 years 前 | 0
已回答
Create a program that asks a user to input a number and then finds the sum of digits of the number using recursion. for example 341 = 3+4+1 = 8
% This program does not require any inbuilt functions. function x = digit_sum(n) x=0; if n>0 x=mod(n,10)+digit_sum(floor...
Create a program that asks a user to input a number and then finds the sum of digits of the number using recursion. for example 341 = 3+4+1 = 8
% This program does not require any inbuilt functions. function x = digit_sum(n) x=0; if n>0 x=mod(n,10)+digit_sum(floor...
4 years 前 | 1