View difference between Paste ID: cu8GDeBA and SZpPjDY8
SHOW: | | - or go back to the newest paste.
1
#include <stdio.h>
2
#include <conio.h>
3
4
int soma = 0;
5
6
int Primo(int num)
7
{	
8
	int completo = 0, atual = 2, i,exato;
9
	while(completo<num){
10
		exato = 0;
11
		for (i = 1; i < atual; i++){
12
			if(atual%i==0){
13
				exato++;
14
			}
15
		}
16
		if(exato==1){
17
			printf("%d ", atual);
18
			completo++;
19
			soma +=atual;
20
		}
21
		atual++;
22
	}
23
}
24
25
int main()
26
{
27
	int n;
28
	printf ("Digite um numero: ");
29
	scanf("%d", &n);
30
	Primo(n);
31-
	printf(" = ", soma);
31+
	printf(" = %d", soma);
32
	getch();
33
}