Advertisement
Guest User

Untitled

a guest
Nov 28th, 2014
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.78 KB | None | 0 0
  1.  
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. void decomposition (int entier, int cpt1, int cpt2);
  5.  
  6. int main()
  7. {
  8.     int entier ;
  9.  
  10.     printf("Exercice 4.2 : \n");
  11.     printf("Entrez votre entier positif : \n");
  12.     scanf("%d", &entier);
  13.     printf("%d = ", entier);
  14.     decomposition(entier, 2, 0);
  15.     return 0;
  16. }
  17.  
  18. void decomposition(int entier, int compteur,int cpt2)
  19. {
  20.  
  21.     if  (entier > 1)
  22.     {
  23.         if (!(entier%compteur))
  24.         {
  25.             cpt2++;
  26.             if ((entier/compteur)%compteur)
  27.             {
  28.                 printf("%d^%d ", compteur,cpt2);
  29.             }
  30.             decomposition(entier / compteur, compteur,cpt2);
  31.         }
  32.         else
  33.         {
  34.             cpt2=0;
  35.             decomposition(entier, ++compteur,cpt2);
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement