MATLAB: Sum of all the prime numbers under 100, sum of the ten smallest prime numbers.

mathematics

As the title says i have to create a program which sums all the prime numbers under 100, and sums the ten smallest prime numbers. I can't use the built in functions like: sum, prime, etc. I tried making a program using those functions and it worked.
I'm thinking about something like this:
i have to write a program that detects a prime number, since a prime number only can be divided by 1 and itself, i need to write a program that detects that.
Then i need to customize it so that it detects all the prime numbers under 100.
Then it needs to sum all of the prime numbers under 100 and displays the "sum".
For the "ten smallest prime numbers", i have no idea to be honest..
Cheers!

Best Answer

Oh come on ...
summe = 0;
nprime = 0;
for i = 2:100
istprime = 1;
for j = 2:i-1
if mod(i,j)==0
istprime = 0;
break;
end
end
if istprime == 1
nprime = nprime + 1;
summe = summe + i;
if nprime == 10
summe_first_ten = summe ;
end
end
end
Best wishes
Torsten.