Test if input number is divisible by 3.

조회 수: 29 (최근 30일)
Bozza
Bozza 2022년 8월 9일
편집: Rik 2022년 10월 6일
I want to write a program to request a number from the user, and do one of two things:
  • If the number is divisible by three, output that it is divisible by 3 and state the quotient.
  • If the number is NOT divisible by three, state this, and report back the quotient and remainder.
  댓글 수: 18
Bozza
Bozza 2022년 8월 9일
I think I just fixed it with some simple maths. Leaving something for a bit can make you realise how easy the solution is :) Thanks for the help everyone.
John D'Errico
John D'Errico 2022년 10월 5일
When you edit away all of your questions, you insult the people who spent the time answering those questions. You hurt answers, since then your question is completely useless for anyone else to ever learn from.
If you were going to delete the question, you should not be asking it in the first place.

댓글을 달려면 로그인하십시오.

답변 (1개)

Bjorn Gustavsson
Bjorn Gustavsson 2022년 8월 9일
Have a look at the help and documentation for while. Also from the question I guess that you're reasonably new to programming. If that's the case have a walk through the on-ramp material. That is designed to get you up to speed with programming, and supposedly no other way should be better than you browsing through that focusing on the parts that are of most interest and relevance to you.
HTH

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by