This commit is contained in:
2026-02-02 03:36:21 +01:00
parent 2ae8d93f16
commit 6841949095
7 changed files with 365 additions and 23 deletions
@@ -0,0 +1,43 @@
#include <stdlib.h>
#include <stdio.h>
//utiliser la recu ?
//possible mais avec fct aux
//malloc dans my_factor puis appelle aux (poineur, n)
int *my_factor(int n){
if (n <= 0) return NULL;
if (n == 1) return 1;
int cnt = 0;
int tmp = n;
int div = 2;
while(tmp > 1){
if (tmp % div == 0){
cnt ++;
tmp = tmp /div
}
else div ++;
}
int *rslt = malloc((cnt + 1)* sizeof(int));
if(rslt == NULL) return NULL;
int index = 0;
int *kebab = rslt;
tmp = n;
div = 2;
while (temps > 1) {
if (tmp % div == 0){
*(kebab + index) = div;
index ++;
tmp = tmp / div;
}
else div ++;
}
*kebab = 0;
return rslt;
}