Created
October 6, 2021 14:28
-
-
Save fabiommendes/5aa4af6ae551c7eb0c758c22488be078 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <math.h> | |
double PI = 3.14; | |
int fat(int n) { | |
if (n == 0) { | |
return 1; | |
} | |
else { | |
return n * fat(n - 1); | |
} | |
} | |
void print_collatz(int n) { | |
while (n != 1) { | |
printf("%d\n", n); | |
if (n % 2 == 0) { | |
n = n / 2; | |
} | |
else { | |
n = 3 * n + 1; | |
} | |
} | |
printf("%d\n", n); | |
} | |
void print_fibo(int n) { | |
int x = 1, y = 1, aux; | |
for (int i = 0; i < n; i++) { | |
printf("%d) %d\n", i, x); | |
aux = x; | |
x = y; | |
y = aux + y; | |
} | |
} | |
int next_collatz(int n) { | |
if (n % 2 == 0) { | |
return n / 2; | |
} | |
else if (n == 1) { | |
return 1; | |
} | |
else { | |
return 3 * n + 1; | |
} | |
} | |
int main() { | |
int n; | |
printf("n: "); | |
scanf("%d", &n); | |
printf("FizzBuzz de 1 até %d\n", n); | |
// ... implemente o fizzbuzz usando o for! | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment