How to do this? need help

조회 수: 1 (최근 30일)
Eli Nitro
Eli Nitro 2020년 4월 20일
답변: Vinai Datta Thatiparthi 2020년 4월 22일
% Use a for-loop to check if each integer from 1 to 100 is a prime, % square or divisible by 6.
% Collect the integers that meet the above conditions to the % correspondent arrays Prime, Square or FactorOf6.
% Create count variables pCount, sCount and fCount which are updated % each time you find a new Prime, Square or FactorOf6 element and use % these counters to add new elements to your arrays.
% Print Prime, Square & FactorOf6 after your for- loop is finished.
  댓글 수: 1
Walter Roberson
Walter Roberson 2020년 4월 20일
search for the posts on the advice we have given other people.

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

답변 (1개)

Vinai Datta Thatiparthi
Vinai Datta Thatiparthi 2020년 4월 22일
These links could be of help:
  • isprime function to check if number is prime or not
  • rem function to check divisibility
  • sqrt function to check square numbers
  • for loop in MATLAB
  • if-else statements in MATLAB
Finally, MATLAB Onramp course is a great way to ramp-up on basics of MATLAB.
Hope this helps!

카테고리

Help CenterFile Exchange에서 Discrete Math에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by