Ans sadiq
Followers: 0 Following: 0
Statistics
0 Questions
2 Answers
RANK
19,277
of 292,798
REPUTATION
2
CONTRIBUTIONS
0 Questions
2 Answers
ANSWER ACCEPTANCE
0.00%
VOTES RECEIVED
1
RANK
of 19,940
REPUTATION
N/A
AVERAGE RATING
0.00
CONTRIBUTIONS
0 Files
DOWNLOADS
0
ALL TIME DOWNLOADS
0
RANK
of 147,963
CONTRIBUTIONS
0 Problems
0 Solutions
SCORE
0
NUMBER OF BADGES
0
CONTRIBUTIONS
0 Posts
CONTRIBUTIONS
0 Public Channels
AVERAGE RATING
CONTRIBUTIONS
0 Highlights
AVERAGE NO. OF LIKES
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.
function out=digit_sum(in) q=in; a=q/10; b=floor(a); c=q-b*10; w=c; if q>0 w=w+digit_sum(b); end out=w; end ...
3 years ago | 0
Sum the digits of a number?
function out=digit_sum(in) q=in; a=q/10; b=floor(a); c=q-b*10; w=c; if q>0 w=w+digit_sum(b); end out=w; end ...
3 years ago | 1