using mod function for checking integers
이전 댓글 표시
I have a short assignment for a MATLAB class and I am in need of a quick refresher and some help. SO The question states that i need to make an Array from 1 to 1000 and divide each of those numbers by an array of the prime numbers 2,3,5,7,11,13,17,23. and if the number in the first array is divisible by the prime number you add 1 to a final array for that prime number. I know what the code should do but not sure how to check if it is divisable by the prime number.
clear clc K = (1:1000) primenum = (2,3,5,7,11,13,17,23) divisable_by_prime = (A,B,C,D,E,F,G,H) if ( part im not sure about) %IF K/2 is an integer A= A+1 else if ( part im not sure about) %IF K/3 is an integer B= B+1 ... so on and so forth. I think you have to use the mod function but i'm not sure how to. any help would be appreciated!
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!