Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <conio.h>
- int soma = 0;
- int Primo(int num)
- {
- int completo = 0, atual = 2, i,exato;
- while(completo<num){
- exato = 0;
- for (i = 1; i < atual; i++){
- if(atual%i==0){
- exato++;
- }
- }
- if(exato==1){
- printf("%d ", atual);
- completo++;
- soma +=atual;
- }
- atual++;
- }
- }
- int main()
- {
- int n;
- printf ("Digite um numero: ");
- scanf("%d", &n);
- Primo(n);
- printf(" = %d", soma);
- getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement