lesson 7 i read the thingy wrong

This commit is contained in:
deck committed 2026-10-06 21:46:11 +02:00
1 parent 8fc7170ccd
commit 6d96a16d20
2 files changed
+16 -17

No files matched your search

+8 -17
View File
@@ -1,25 +1,16 @@
#include <stdio.h>
int main(void) {
int n;
scanf("%d", &n);
int resultof3 = n%3;
int resultof5 = n%5;
if (!resultof5 && !resultof3) {
printf("FizzBuzz");
} else if (!resultof3) {
printf("Fizz");
} else if (!resultof5) {
printf("Buzz");
} else {
printf("%d", n);
}
/* TODO: print exactly one line:
multiple of 3 and 5 -> FizzBuzz
multiple of 3 only -> Fizz
multiple of 5 only -> Buzz
anything else -> the number itself */
long long result = 0;
long imat = 1;
while (!(imat>n)) {
result = result +imat;
imat = imat+2;
}
printf("%lld", result);
return 0;
}