diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000000000000000000000000000000000000..edd66815436a11f010e6e676930298e683036792 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,16 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "lldb", + "request": "launch", + "name": "Debug", + "program": "${workspaceFolder}/myTP/exos/exo1", + "args": [], + "cwd": "${workspaceFolder}" + } + ] +} \ No newline at end of file diff --git a/myTP/exos/exo1 b/myTP/exos/exo1 new file mode 100755 index 0000000000000000000000000000000000000000..3c7a594c631cf340dc110f33cd270e0c3d91b688 Binary files /dev/null and b/myTP/exos/exo1 differ diff --git a/myTP/exos/exo1.c b/myTP/exos/exo1.c new file mode 100644 index 0000000000000000000000000000000000000000..5fd722573e69aacff05ec0af828226512165bbca --- /dev/null +++ b/myTP/exos/exo1.c @@ -0,0 +1,89 @@ +#include <stdio.h> +#include <stdlib.h> +#include <math.h> + +int Prime(); +int factoriel(int n); +int perfect(int num); + +int main(){ + + + //printf("%u",Prime()); + + //printf("%u ",factoriel(4)); + perfect(0); + + palindrome(0,"kayak"); + +} + + +int Prime(){ + + int n=1000; + while(n<=1000){ + + for(int i=0; i<sqrt(n); i++){ + + if (n % 2 !=0){ + printf("%u\n",n); + + break; + } + + } + n--; + } +} + +int factoriel(int n){ + + if (n > 1) { + return n * printf("%u \n",factoriel(n - 1)); + } else { + return 1; + } +} + +int perfect(int num){ + + int sum=0,i; + + while(num<=1000) { + + sum=0; + for(i=1;i<num;i++){ + + if(num % i==0){ + sum+=i; + } + } + + if (sum==num){ + + printf("%d is perfect\n",num); + + } + num++; + + } +} + +bool palindrome(int n ,char* mot){ + + length=strlen(mot)-1 + + if(mot[n]==mot[length]){ + + if (index+1 ==len ||index==len){ + + printf("pal") + } + palindrome(index+1,mot); + }else{ + printf("not pal") + } + + + } \ No newline at end of file