-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathprime2.c
47 lines (29 loc) · 863 Bytes
/
prime2.c
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
// OG Trio
// Louie Kotler, Simone Stern, Chris Narducci
#include <stdio.h>
#include <math.h>
int main() {
int num, x, nonprime = 0;
int total = 0, totalsq = 0, counter = 0;
for (num = 2; num <= 50; num++)
{
for (x = 2; x < num; x++)
{
if (num % x == 0)
{
nonprime = 1;
}
}
if (nonprime == 0)
{
printf("%d for %d\n", num*num, num);
total = total + num;
totalsq = totalsq + num * num;
counter++;
}
nonprime = 0;
}
printf("\nAvg for total: %d\n", total/counter);
printf("Avg for squared total: %d\n", totalsq/counter);
return 0;
}