-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMonitoria_3.c
More file actions
64 lines (59 loc) · 903 Bytes
/
Copy pathMonitoria_3.c
File metadata and controls
64 lines (59 loc) · 903 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <stdio.h>
#include <stdlib.h>
int somadosdigitos(int n);
void parImpar(int n);
void valorPrimo(int n);
int somadosdigitos(int n){
int soma = 0;
float resto;
if (n % 10 == n)
{
return n;
}
while (n > 0)
{
resto = n % 10;
soma += resto;
n /= 10;
}
return soma;
}
void parImpar(int n){
if ((n%2) == 0){
printf("Par ");
}else{
printf("Impar ");
}
}
void valorPrimo(int n){
int i = 2;
int resultado = 0;
for (i; i < 99999; i++)
{
resultado = n % i;
if ((resultado == 0 && n != i) || n == 1)
{
printf("Nao e primo\n");
return;
}
}
printf("Primo\n");
}
int main(){
int N, valor = 0;
scanf("%d", &N);
if (N < 10)
{
printf("%d ", N);
parImpar(N);
valorPrimo(N);
}
while (N >= 10)
{
N = somadosdigitos(N);
printf("%d ", N);
parImpar(N);
valorPrimo(N);
}
return 0;
}