Skip to content
Snippets Groups Projects
Commit 1028c267 authored by mathias.catala's avatar mathias.catala
Browse files

"yes"

parent 389c2b90
No related branches found
No related tags found
No related merge requests found
{
// 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
File added
#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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment