Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- void decomposition (int entier, int cpt1, int cpt2);
- int main()
- {
- int entier ;
- printf("Exercice 4.2 : \n");
- printf("Entrez votre entier positif : \n");
- scanf("%d", &entier);
- printf("%d = ", entier);
- decomposition(entier, 2, 0);
- return 0;
- }
- void decomposition(int entier, int compteur,int cpt2)
- {
- if (entier > 1)
- {
- if (!(entier%compteur))
- {
- cpt2++;
- if ((entier/compteur)%compteur)
- {
- printf("%d^%d ", compteur,cpt2);
- }
- decomposition(entier / compteur, compteur,cpt2);
- }
- else
- {
- cpt2=0;
- decomposition(entier, ++compteur,cpt2);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement