diff options
| author | Charles <sircharlesaze@gmail.com> | 2019-07-07 15:29:30 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2019-07-07 15:29:30 +0200 |
| commit | a2ef228b981df5ad417a0e8377e1e832002a7644 (patch) | |
| tree | 32827b5be808bf3123d46856bb753fc190fd3611 /c05/main.c | |
| parent | 79f8ba0b777f3361002ed2ae0c6c6f8f353ca731 (diff) | |
| download | piscine-a2ef228b981df5ad417a0e8377e1e832002a7644.tar.gz piscine-a2ef228b981df5ad417a0e8377e1e832002a7644.tar.bz2 piscine-a2ef228b981df5ad417a0e8377e1e832002a7644.zip | |
c04/c05 testing + c06
Diffstat (limited to 'c05/main.c')
| -rw-r--r-- | c05/main.c | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/c05/main.c b/c05/main.c new file mode 100644 index 0000000..ca9a1c1 --- /dev/null +++ b/c05/main.c @@ -0,0 +1,76 @@ +#include <stdio.h> +#include <string.h> +#include <limits.h> +#include "ex00/ft_iterative_factorial.c" +#include "ex01/ft_recursive_factorial.c" +#include "ex02/ft_iterative_power.c" +#include "ex03/ft_recursive_power.c" +#include "ex04/ft_fibonacci.c" +#include "ex05/ft_sqrt.c" +#include "ex06/ft_is_prime.c" +#include "ex07/ft_find_next_prime.c" + +int main() +{ + printf("%d! = %d\n", -1, ft_iterative_factorial(-1)); + printf("%d! = %d\n", 0, ft_iterative_factorial(0)); + printf("%d! = %d\n", 1, ft_iterative_factorial(1)); + printf("%d! = %d\n", 4, ft_iterative_factorial(4)); + printf("%d! = %d\n", 6, ft_iterative_factorial(6)); + printf("%d! = %d\n", 10, ft_iterative_factorial(10)); + + printf("---------------------\n"); + printf("%d! = %d\n", -1, ft_recursive_factorial(-1)); + printf("%d! = %d\n", 0, ft_recursive_factorial(0)); + printf("%d! = %d\n", 1, ft_recursive_factorial(1)); + printf("%d! = %d\n", 4, ft_recursive_factorial(4)); + printf("%d! = %d\n", 6, ft_recursive_factorial(6)); + printf("%d! = %d\n", 10, ft_recursive_factorial(10)); + + printf("---------------------\n"); + printf("%d^%d = %d\n", 2, 0, ft_iterative_power(2, 0)); + printf("%d^%d = %d\n", 2, 2, ft_iterative_power(2, 4)); + printf("%d^%d = %d\n", 3, 3, ft_iterative_power(3, 3)); + printf("%d^%d = %d\n", 4, 5, ft_iterative_power(4, 5)); + + printf("---------------------\n"); + printf("%d^%d = %d\n", 2, 0, ft_recursive_power(2, 0)); + printf("%d^%d = %d\n", 2, 2, ft_recursive_power(2, 4)); + printf("%d^%d = %d\n", 3, 3, ft_recursive_power(3, 3)); + printf("%d^%d = %d\n", 4, 5, ft_recursive_power(4, 5)); + + printf("---------------------\n"); + printf("F%d = %d\n", -1, ft_fibonacci(-1)); + printf("F%d = %d\n", 0, ft_fibonacci(0)); + printf("F%d = %d\n", 1, ft_fibonacci(1)); + printf("F%d = %d\n", 2, ft_fibonacci(2)); + printf("F%d = %d\n", 3, ft_fibonacci(3)); + printf("F%d = %d\n", 8, ft_fibonacci(8)); + printf("F%d = %d\n", 30, ft_fibonacci(30)); + /*printf("F%d = %d\n", 41, ft_fibonacci(41));*/ + + printf("---------------------\n"); + printf("sqrt(%d) = %d\n", -36, ft_sqrt(-36)); + printf("sqrt(%d) = %d\n", 0, ft_sqrt(0)); + printf("sqrt(%d) = %d\n", 4, ft_sqrt(4)); + printf("sqrt(%d) = %d\n", 9, ft_sqrt(4)); + printf("sqrt(%d) = %d\n", 678, ft_sqrt(678 * 678)); + + printf("---------------------\n"); + printf("prime(%d) = %d\n", 3, ft_is_prime(3)); + printf("prime(%d) = %d\n", 25, ft_is_prime(25)); + printf("prime(%d) = %d\n", 17, ft_is_prime(17)); + printf("prime(%d) = %d\n", 21, ft_is_prime(21)); + printf("prime(%d) = %d\n", 36, ft_is_prime(36)); + printf("prime(%d) = %d\n", 2147483617, ft_is_prime(2147483617)); + /*printf("prime(%d) = %d\n", 2147483629, ft_is_prime(2147483629));*/ + /*for (int i = INT_MAX; i > INT_MAX - 100; i--)*/ + /*printf("%d is %d\n", i, ft_is_prime(i));*/ + + printf("---------------------\n"); + printf("nextp(%d) = %d\n", 21, ft_find_next_prime(21)); + printf("nextp(%d) = %d\n", 23, ft_find_next_prime(23)); + printf("nextp(%d) = %d\n", 2147483600, ft_find_next_prime(2147483600)); + /*for (int i = INT_MAX; i > INT_MAX - 100; i--)*/ + /*printf("%d is %d\n", i, ft_find_next_prime(i));*/ +} |
