-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProjectEuler.c
More file actions
40 lines (38 loc) · 1.07 KB
/
Copy pathProjectEuler.c
File metadata and controls
40 lines (38 loc) · 1.07 KB
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
// projecteuler.net: problem 1
// find the sum of all multiples
// of 3 and 5 from 1 to 1000
#include <stdio.h>
int problemOne(){
int ceiling = 1000;
int sum = 0;
for(int i = 1; i<ceiling;i++){
if((i%3)==0 || (i%5)==0){
sum += i;
}
}
printf("The sum of all multiples of 3 and 5, between 1 and %d is %d", ceiling, sum);
return 1;
}
// ############################################################################################### \\
\\ ############################################################################################### //
// projecteuler.net: problem 63 Powerful Digit Counts
// find numbers where n^m = a
// and a is m digits long.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int problem63(){
intmax_t current = 0;
char currentC[200];
for(int a = 1; a<100;a++){
for(int b = 1; b<100;b++){
current = pow(a, b);
sprintf(currentC, "%ld", current);
if(strlen(currentC) == b){
printf("%d ^ %d = %jd\n", a, b, current);
}
}
}
return 1;
}