using mod function for checking integers
Show older comments
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!
Accepted Answer
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!