-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp179.c
41 lines (36 loc) · 805 Bytes
/
p179.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
#include <stdio.h>
#include <math.h>
#define TH 0.000001
int ndivisors(int num){
int total = 0;
if (num>3){
for (int i=1; i <= (num/2) + 1; i++){
if ((num % i) == 0) {
total += 1;
}
}
return total + 1;
}
else{
return num;
}
}
int main(void){
unsigned int ndivs1 = 1;
unsigned int ndivs2;
unsigned int n, cont;
cont = 0;
for( n = 1; n < 10000000; n++){
ndivs2 = ndivisors(n);
//printf(" %d %d %d \n", n, ndivs2, ndivs1);
if (ndivs2 == ndivs1){
cont++;
}
if ((n % 10000) == 0) {
printf("Num:%d, pairs:%d\n", n, cont);
}
ndivs1 = ndivs2;
}
printf("Num:%d, pairs:%d\n", n, cont);
return 0;
}