Question

SOLVE IN MATLAB 11. Find the 5-digit number that satisfies the following properties: a. sum of...

SOLVE IN MATLAB

11. Find the 5-digit number that satisfies the following properties: a. sum of all the digits is 23 b. sum of the first three digits is 16 c. sum of the first two digits is equal to the third digit d. third digit is twice the fourth digit e. subtracting the fourth digit from the second digit returns the fifth digit

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please find the code below::::

clc
clear
foundNumber=0;
for loop=10000:99999
num = loop;
digit=zeros(1,5);
for i = 1:5
digit(i) = mod(num,10);
num = floor(num/10);
end
condition1 = sum(digit)==23;
condition2 = ((digit(1)+digit(2)+digit(3))==16);
condition3 =(((digit(1)+digit(2))==digit(3)));
condition4 = digit(3)==2*digit(4);
condition5 = (digit(2)-digit(4))==digit(5);
if(condition1 &&condition2 && condition3 && condition4&& condition5)
foundNumber = loop;
break;
end
end

fprintf("The number is %d\n",foundNumber);

output:

Add a comment
Know the answer?
Add Answer to:
SOLVE IN MATLAB 11. Find the 5-digit number that satisfies the following properties: a. sum of...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT