/*************************************************************************************************************************************/
/*                                                                                                                                   */
/*        E T U D E   D E   L A   P E R S I S T A N C E   M U L T I P L I C A T I V E   D E S   N O M B R E S  :                     */
/*                                                                                                                                   */
/*                                                                                                                                   */
/*        Author of '$xtc/PersistanceMultiplicative.11$c' :                                                                          */
/*                                                                                                                                   */
/*                    Jean-Francois Colonna (LACTAMME, 20130531072529).                                                              */
/*                                                                                                                                   */
/*************************************************************************************************************************************/

#include  "INCLUDES.01.I"

#define   BASE      10

#define   N1        1
#define   N2        99

main()
          {
          int       NombreCourant;
          int       PersistanceMaximale=-1;

          for       (NombreCourant=N1 ; NombreCourant<=N2 ; NombreCourant++)
                    {
                    int       Reduction=NombreCourant;
                    int       Persistance=0;

                    printf("%d",NombreCourant);

                    while     (Reduction >= BASE)
                              {
                              int       Cumul=1;
                              int       Quotient=Reduction;
                              int       Reste;

                              while     (Quotient != 0)
                                        {
                                        Reste = Quotient%BASE;
                                        Quotient = Quotient/BASE;
                                        Cumul = Cumul*Reste;
                                        }

                              Reduction = Cumul;

                              printf(" --> %d",Reduction);
                              Persistance++;
                              }

                    PersistanceMaximale=MAX2(PersistanceMaximale,Persistance);
                    printf("     p=%d (base=%d)\n",Persistance,BASE);
                    }

          printf("PersistanceMaximale=%d\n",PersistanceMaximale);
          }



Copyright © Jean-François Colonna, 2021-2021.
Copyright © CMAP (Centre de Mathématiques APpliquées) UMR CNRS 7641 / Ecole Polytechnique, 2021-2021.