Map get_prime_factors_of_tr(uint64_t n) { if (n%2 ==0) { return get_prime_factors(n/2) + get_prime_factors(n + 1); } else { return get_prime_factors(n) + get_prime_factors((n + 1)/2); } }
int main() { int x = input("Enter number"); Stack* factors = get_prime_factors(x); if (is_empty(factors)) { printf("0\n"); return 1; } int all_factors_count = 1; // including prime factors print(factors); printf("\n"); while ((factors = get_next_factors(factors)) != NULL && !is_empty(factors) && top(factors) != x) { all_factors_count++; print(factors); printf("\n"); } printf("\n%d\n", all_factors_count); return 0; }
void *print_prime_factors(void) { uint64_t factors[MAX_FACTORS]; int j,k; uint64_t n; pthread_mutex_lock(&muMuTeTex); int retourRead = fscanf(file, "%ju",&n); pthread_mutex_unlock(&muMuTeTex); while(retourRead!=EOF){ k = get_prime_factors(n,factors); decomp a; a.size=k; a.n=n; a.factors=factors; enregistrer(a); pthread_mutex_lock(&ecran); printf("%ju :",n); for(j=0;j<k;j++) { printf(" %ju",factors[j]); } printf("\n"); pthread_mutex_unlock(&ecran); pthread_mutex_lock(&muMuTeTex); retourRead = fscanf(file, "%ju",&n); pthread_mutex_unlock(&muMuTeTex); } return NULL; }
uint64_t num_divisors(uint64_t n) { uint64_t result = 1; for (auto pair : get_prime_factors(n)) { result *= (pair.second + 1); } return result; }
int main() { std::cout << "i tr(i) prime factors" << std::endl; for (unsigned i = 2; i < 20; ++i) { auto tr = triangle(i); std::cout << i << "\t" << tr << "\t" << get_prime_factors(tr) << std::endl; } }
unsigned num_divisors(unsigned n) { unsigned result = 1; for (auto pair : get_prime_factors(n)) { result *= (pair.second + 1); } return result; }
int get_prime_factors(uint64_t n, uint64_t* dest, uint64_t number) { uint64_t i,limit = sqrt(number); for(i=2 ; i<=limit ; i++) { if(number%i == 0) { dest[n] = i; return get_prime_factors(n+1, dest, number/i); } } dest[n] = number; return n; }
/* * Procedure qui affiche les facteurs premiers d'un nombre sur 64 bits */ void print_prime_factors(uint64_t n) { uint64_t factors[MAX_FACTORS]; int j,k; k = get_prime_factors(n,factors); pthread_mutex_lock(&mutexAffichage); printf("%" SCNu64":",n); for(j=0; j<k; ++j) { printf(" %"SCNu64,factors[j]); } printf("\n"); pthread_mutex_unlock(&mutexAffichage); }
void print_prime_factors(uint64_t n) { uint64_t factors[MAX_FACTORS]; int j,k; k=get_prime_factors(0,factors, n); printf("%ju: ",n); for(j=0; j<=k; j++) { printf("%ju ",factors[j]); } printf("\n"); }
int get_factors(ulong n, ulong *lst) { int n_f, len, len2, i, j, k, p; prime_factor f[100]; n_f = get_prime_factors(n, f); len2 = len = lst[0] = 1; /* L = (1); L = (L, L * p**(1 .. e)) forall((p, e)) */ for (i = 0; i < n_f; i++, len2 = len) for (j = 0, p = f[i].p; j < f[i].e; j++, p *= f[i].p) for (k = 0; k < len2; k++) lst[len++] = lst[k] * p; qsort(lst, len, sizeof(ulong), ulong_cmp); return len; }
void print_prime_factors(uint64_t n, pthread_mutex_t * mutexEcran) { uint64_t factors[MAX_FACTORS]; int j,k; k=get_prime_factors(0,factors, n); pthread_mutex_lock(mutexEcran); // vérouiller mutexEcran printf("%ju: ",n); for(j=0; j<=k; j++) { printf("%ju ",factors[j]); } printf("\n"); pthread_mutex_unlock(mutexEcran); // dévérouiller mutexEcran }
////////////////////////////////////////////////////////////////// PUBLIC //---------------------------------------------------- Fonctions publiques int main ( void ) { InitMemoire ( ); racine = GetRoot ( ); FILE * lecture = fopen ( "input.txt" , "r"); uint64_t * nombre = malloc ( sizeof ( uint64_t ) ); while ( EOF != (fscanf ( lecture, "%" PRIu64 "", nombre ) ) ) { get_prime_factors ( * nombre ); print_prime_factors ( * nombre ); } End ( racine ); return 0; } //----- fin de Main
static void print_prime_factors(uint64_t n) { uint64_t factors[MAX_FACTORS]; int j,k; k=get_prime_factors(n,factors); pthread_mutex_lock(&mtxAffichage); printf("%ju: ",n); for(j=0; j<k; j++) { printf("%ju ",factors[j]); } pthread_mutex_unlock(&mtxAffichage); printf("\n"); }
INT X(find_generator)(INT p) { INT n, i, size; INT primef[16]; /* smallest number = 32589158477190044730 > 2^64 */ INT pm1 = p - 1; if (p == 2) return 1; size = get_prime_factors(pm1, primef); n = 2; for (i = 0; i < size; i++) if (X(power_mod)(n, pm1 / primef[i], p) == 1) { i = -1; n++; } return n; }
void threadMain ( void * thrData ) { uint64_t nombre; facteur * nombreCalcule; //On veut lire, on protège pthread_mutex_lock ( &mutexLecture ); while ( EOF != (fscanf ( lecture, "%" PRIu64 "", &nombre ) ) ) { //Lecture effectuée, on rends l'accès pthread_mutex_unlock ( &mutexLecture ); //Calcul des facteurs nombreCalcule = get_prime_factors ( nombre ); //Affichage print_prime_factors ( nombreCalcule ); } pthread_mutex_unlock ( &mutexLecture ); }
unsigned get_smallest_evenly_divisible(unsigned n) { std::map<value_type, count_type> result; for (unsigned i = 2; i <= n; ++i) { for (const auto & value_and_count : get_prime_factors(i)) { auto value = value_and_count.first; auto count = value_and_count.second; result[value] = std::max(result[value], count); } } unsigned product = 1; for (const auto & p : result) { for (auto i = 0u; i < p.second; ++i) { product *= p.first; } } return product; }
int main(int argc, char *argv[]) { FILE *bytemaskfile; float **dataavg = NULL, **datastd = NULL, **datapow = NULL; float *chandata = NULL, powavg, powstd, powmax; float inttime, norm, fracterror = RFI_FRACTERROR; float *rawdata = NULL; unsigned char **bytemask = NULL; short *srawdata = NULL; char *outfilenm, *statsfilenm, *maskfilenm; char *bytemaskfilenm, *rfifilenm; int numchan = 0, numint = 0, newper = 0, oldper = 0, good_padvals = 0; int blocksperint, ptsperint = 0, ptsperblock = 0, padding = 0; int numcands, candnum, numrfi = 0, numrfivect = NUM_RFI_VECT; int ii, jj, kk, slen, numread = 0, insubs = 0; int harmsum = RFI_NUMHARMSUM, lobin = RFI_LOBIN, numbetween = RFI_NUMBETWEEN; double davg, dvar, freq; struct spectra_info s; presto_interptype interptype; rfi *rfivect = NULL; mask oldmask, newmask; fftcand *cands; infodata idata; Cmdline *cmd; /* Call usage() if we have no command line arguments */ if (argc == 1) { Program = argv[0]; printf("\n"); usage(); exit(0); } /* Parse the command line using the excellent program Clig */ cmd = parseCmdline(argc, argv); spectra_info_set_defaults(&s); s.filenames = cmd->argv; s.num_files = cmd->argc; s.clip_sigma = cmd->clip; // -1 causes the data to determine if we use weights, scales, & // offsets for PSRFITS or flip the band for any data type where // we can figure that out with the data s.apply_flipband = (cmd->invertP) ? 1 : -1; s.apply_weight = (cmd->noweightsP) ? 0 : -1; s.apply_scale = (cmd->noscalesP) ? 0 : -1; s.apply_offset = (cmd->nooffsetsP) ? 0 : -1; s.remove_zerodm = (cmd->zerodmP) ? 1 : 0; if (cmd->noclipP) { cmd->clip = 0.0; s.clip_sigma = 0.0; } if (cmd->ifsP) { // 0 = default or summed, 1-4 are possible also s.use_poln = cmd->ifs; } slen = strlen(cmd->outfile) + 20; #ifdef DEBUG showOptionValues(); #endif printf("\n\n"); printf(" Pulsar Data RFI Finder\n"); printf(" by Scott M. Ransom\n\n"); /* The following is the root of all the output files */ outfilenm = (char *) calloc(slen, sizeof(char)); sprintf(outfilenm, "%s_rfifind", cmd->outfile); /* And here are the output file names */ maskfilenm = (char *) calloc(slen, sizeof(char)); sprintf(maskfilenm, "%s.mask", outfilenm); bytemaskfilenm = (char *) calloc(slen, sizeof(char)); sprintf(bytemaskfilenm, "%s.bytemask", outfilenm); rfifilenm = (char *) calloc(slen, sizeof(char)); sprintf(rfifilenm, "%s.rfi", outfilenm); statsfilenm = (char *) calloc(slen, sizeof(char)); sprintf(statsfilenm, "%s.stats", outfilenm); sprintf(idata.name, "%s", outfilenm); if (RAWDATA) { if (cmd->filterbankP) s.datatype = SIGPROCFB; else if (cmd->psrfitsP) s.datatype = PSRFITS; else if (cmd->pkmbP) s.datatype = SCAMP; else if (cmd->bcpmP) s.datatype = BPP; else if (cmd->wappP) s.datatype = WAPP; else if (cmd->spigotP) s.datatype = SPIGOT; } else { // Attempt to auto-identify the data identify_psrdatatype(&s, 1); if (s.datatype==SIGPROCFB) cmd->filterbankP = 1; else if (s.datatype==PSRFITS) cmd->psrfitsP = 1; else if (s.datatype==SCAMP) cmd->pkmbP = 1; else if (s.datatype==BPP) cmd->bcpmP = 1; else if (s.datatype==WAPP) cmd->wappP = 1; else if (s.datatype==SPIGOT) cmd->spigotP = 1; else if (s.datatype==SUBBAND) insubs = 1; else { printf("Error: Unable to identify input data files. Please specify type.\n\n"); exit(1); } } if (!cmd->nocomputeP) { if (RAWDATA || insubs) { char description[40]; psrdatatype_description(description, s.datatype); if (s.num_files > 1) printf("Reading %s data from %d files:\n", description, s.num_files); else printf("Reading %s data from 1 file:\n", description); if (insubs) s.files = (FILE **)malloc(sizeof(FILE *) * s.num_files); for (ii = 0; ii < s.num_files; ii++) { printf(" '%s'\n", cmd->argv[ii]); if (insubs) s.files[ii] = chkfopen(cmd->argv[ii], "rb"); } printf("\n"); } if (RAWDATA) { read_rawdata_files(&s); print_spectra_info_summary(&s); spectra_info_to_inf(&s, &idata); ptsperblock = s.spectra_per_subint; numchan = s.num_channels; idata.dm = 0.0; } if (insubs) { /* Set-up values if we are using subbands */ char *tmpname, *root, *suffix; if (split_root_suffix(s.filenames[0], &root, &suffix) == 0) { printf("Error: The input filename (%s) must have a suffix!\n\n", s.filenames[0]); exit(1); } if (strncmp(suffix, "sub", 3) == 0) { tmpname = calloc(strlen(root) + 6, 1); sprintf(tmpname, "%s.sub", root); readinf(&idata, tmpname); free(tmpname); } else { printf("\nThe input files (%s) must be subbands! (i.e. *.sub##)\n\n", s.filenames[0]); exit(1); } free(root); free(suffix); ptsperblock = 1; /* Compensate for the fact that we have subbands and not channels */ idata.freq = idata.freq - 0.5 * idata.chan_wid + 0.5 * idata.chan_wid * (idata.num_chan / s.num_files); idata.chan_wid = idata.num_chan / s.num_files * idata.chan_wid; idata.num_chan = numchan = s.num_files; idata.dm = 0.0; sprintf(idata.name, "%s", outfilenm); writeinf(&idata); s.padvals = gen_fvect(s.num_files); for (ii = 0 ; ii < s.num_files ; ii++) s.padvals[ii] = 0.0; } /* Read an input mask if wanted */ if (cmd->maskfileP) { read_mask(cmd->maskfile, &oldmask); printf("Read old mask information from '%s'\n\n", cmd->maskfile); good_padvals = determine_padvals(cmd->maskfile, &oldmask, s.padvals); } else { oldmask.numchan = oldmask.numint = 0; } /* The number of data points and blocks to work with at a time */ if (cmd->blocksP) { blocksperint = cmd->blocks; cmd->time = blocksperint * ptsperblock * idata.dt; } else { blocksperint = (int) (cmd->time / (ptsperblock * idata.dt) + 0.5); } ptsperint = blocksperint * ptsperblock; numint = (long long) idata.N / ptsperint; if ((long long) idata.N % ptsperint) numint++; inttime = ptsperint * idata.dt; printf("Analyzing data sections of length %d points (%.6g sec).\n", ptsperint, inttime); { int *factors, numfactors; factors = get_prime_factors(ptsperint, &numfactors); printf(" Prime factors are: "); for (ii = 0; ii < numfactors; ii++) printf("%d ", factors[ii]); printf("\n"); if (factors[numfactors - 1] > 13) { printf(" WARNING: The largest prime factor is pretty big! This will\n" " cause the FFTs to take a long time to compute. I\n" " recommend choosing a different -time value.\n"); } printf("\n"); free(factors); } /* Allocate our workarrays */ if (RAWDATA) rawdata = gen_fvect(idata.num_chan * ptsperblock * blocksperint); else if (insubs) srawdata = gen_svect(idata.num_chan * ptsperblock * blocksperint); dataavg = gen_fmatrix(numint, numchan); datastd = gen_fmatrix(numint, numchan); datapow = gen_fmatrix(numint, numchan); chandata = gen_fvect(ptsperint); bytemask = gen_bmatrix(numint, numchan); for (ii = 0; ii < numint; ii++) for (jj = 0; jj < numchan; jj++) bytemask[ii][jj] = GOODDATA; rfivect = rfi_vector(rfivect, numchan, numint, 0, numrfivect); if (numbetween == 2) interptype = INTERBIN; else interptype = INTERPOLATE; /* Main loop */ printf("Writing mask data to '%s'.\n", maskfilenm); printf("Writing RFI data to '%s'.\n", rfifilenm); printf("Writing statistics to '%s'.\n\n", statsfilenm); printf("Massaging the data ...\n\n"); printf("Amount Complete = %3d%%", oldper); fflush(stdout); for (ii = 0; ii < numint; ii++) { /* Loop over the intervals */ newper = (int) ((float) ii / numint * 100.0 + 0.5); if (newper > oldper) { printf("\rAmount Complete = %3d%%", newper); fflush(stdout); oldper = newper; } /* Read a chunk of data */ if (RAWDATA) numread = read_rawblocks(rawdata, blocksperint, &s, &padding); else if (insubs) numread = read_subband_rawblocks(s.files, s.num_files, srawdata, blocksperint, &padding); if (padding) for (jj = 0; jj < numchan; jj++) bytemask[ii][jj] |= PADDING; for (jj = 0; jj < numchan; jj++) { /* Loop over the channels */ if (RAWDATA) get_channel(chandata, jj, blocksperint, rawdata, &s); else if (insubs) get_subband(jj, chandata, srawdata, blocksperint); /* Calculate the averages and standard deviations */ /* for each point in time. */ if (padding) { dataavg[ii][jj] = 0.0; datastd[ii][jj] = 0.0; datapow[ii][jj] = 1.0; } else { avg_var(chandata, ptsperint, &davg, &dvar); dataavg[ii][jj] = davg; datastd[ii][jj] = sqrt(dvar); realfft(chandata, ptsperint, -1); numcands = 0; norm = datastd[ii][jj] * datastd[ii][jj] * ptsperint; if (norm == 0.0) norm = (chandata[0] == 0.0) ? 1.0 : chandata[0]; cands = search_fft((fcomplex *) chandata, ptsperint / 2, lobin, ptsperint / 2, harmsum, numbetween, interptype, norm, cmd->freqsigma, &numcands, &powavg, &powstd, &powmax); datapow[ii][jj] = powmax; /* Record the birdies */ if (numcands) { for (kk = 0; kk < numcands; kk++) { freq = cands[kk].r / inttime; candnum = find_rfi(rfivect, numrfi, freq, RFI_FRACTERROR); if (candnum >= 0) { update_rfi(rfivect + candnum, freq, cands[kk].sig, jj, ii); } else { update_rfi(rfivect + numrfi, freq, cands[kk].sig, jj, ii); numrfi++; if (numrfi == numrfivect) { numrfivect *= 2; rfivect = rfi_vector(rfivect, numchan, numint, numrfivect / 2, numrfivect); } } } free(cands); } } } } printf("\rAmount Complete = 100%%\n"); /* Write the data to the output files */ write_rfifile(rfifilenm, rfivect, numrfi, numchan, numint, ptsperint, lobin, numbetween, harmsum, fracterror, cmd->freqsigma); write_statsfile(statsfilenm, datapow[0], dataavg[0], datastd[0], numchan, numint, ptsperint, lobin, numbetween); } else { /* If "-nocompute" */ float freqsigma; /* Read the data from the output files */ printf("Reading RFI data from '%s'.\n", rfifilenm); printf("Reading statistics from '%s'.\n", statsfilenm); readinf(&idata, outfilenm); read_rfifile(rfifilenm, &rfivect, &numrfi, &numchan, &numint, &ptsperint, &lobin, &numbetween, &harmsum, &fracterror, &freqsigma); numrfivect = numrfi; read_statsfile(statsfilenm, &datapow, &dataavg, &datastd, &numchan, &numint, &ptsperint, &lobin, &numbetween); bytemask = gen_bmatrix(numint, numchan); printf("Reading bytemask from '%s'.\n\n", bytemaskfilenm); bytemaskfile = chkfopen(bytemaskfilenm, "rb"); chkfread(bytemask[0], numint * numchan, 1, bytemaskfile); fclose(bytemaskfile); for (ii = 0; ii < numint; ii++) for (jj = 0; jj < numchan; jj++) bytemask[ii][jj] &= PADDING; /* Clear all but the PADDING bits */ inttime = ptsperint * idata.dt; } /* Make the plots and set the mask */ { int *zapints, *zapchan; int numzapints = 0, numzapchan = 0; if (cmd->zapintsstrP) { zapints = ranges_to_ivect(cmd->zapintsstr, 0, numint - 1, &numzapints); zapints = (int *) realloc(zapints, (size_t) (sizeof(int) * numint)); } else { zapints = gen_ivect(numint); } if (cmd->zapchanstrP) { zapchan = ranges_to_ivect(cmd->zapchanstr, 0, numchan - 1, &numzapchan); zapchan = (int *) realloc(zapchan, (size_t) (sizeof(int) * numchan)); } else { zapchan = gen_ivect(numchan); } rfifind_plot(numchan, numint, ptsperint, cmd->timesigma, cmd->freqsigma, cmd->inttrigfrac, cmd->chantrigfrac, dataavg, datastd, datapow, zapchan, numzapchan, zapints, numzapints, &idata, bytemask, &oldmask, &newmask, rfivect, numrfi, cmd->rfixwinP, cmd->rfipsP, cmd->xwinP); vect_free(zapints); vect_free(zapchan); } /* Write the new mask and bytemask to the file */ write_mask(maskfilenm, &newmask); bytemaskfile = chkfopen(bytemaskfilenm, "wb"); chkfwrite(bytemask[0], numint * numchan, 1, bytemaskfile); fclose(bytemaskfile); /* Determine the percent of good and bad data */ { int numpad = 0, numbad = 0, numgood = 0; for (ii = 0; ii < numint; ii++) { for (jj = 0; jj < numchan; jj++) { if (bytemask[ii][jj] == GOODDATA) { numgood++; } else { if (bytemask[ii][jj] & PADDING) numpad++; else numbad++; } } } printf("\nTotal number of intervals in the data: %d\n\n", numint * numchan); printf(" Number of padded intervals: %7d (%6.3f%%)\n", numpad, (float) numpad / (float) (numint * numchan) * 100.0); printf(" Number of good intervals: %7d (%6.3f%%)\n", numgood, (float) numgood / (float) (numint * numchan) * 100.0); printf(" Number of bad intervals: %7d (%6.3f%%)\n\n", numbad, (float) numbad / (float) (numint * numchan) * 100.0); qsort(rfivect, numrfi, sizeof(rfi), compare_rfi_sigma); printf(" Ten most significant birdies:\n"); printf("# Sigma Period(ms) Freq(Hz) Number \n"); printf("----------------------------------------------------\n"); for (ii = 0; ii < 10; ii++) { double pperr; char temp1[40], temp2[40]; if (rfivect[ii].freq_var == 0.0) { pperr = 0.0; sprintf(temp1, " %-14g", rfivect[ii].freq_avg); sprintf(temp2, " %-14g", 1000.0 / rfivect[ii].freq_avg); } else { pperr = 1000.0 * sqrt(rfivect[ii].freq_var) / (rfivect[ii].freq_avg * rfivect[ii].freq_avg); nice_output_2(temp1, rfivect[ii].freq_avg, sqrt(rfivect[ii].freq_var), -15); nice_output_2(temp2, 1000.0 / rfivect[ii].freq_avg, pperr, -15); } printf("%-2d %-8.2f %13s %13s %-8d\n", ii + 1, rfivect[ii].sigma_avg, temp2, temp1, rfivect[ii].numobs); } qsort(rfivect, numrfi, sizeof(rfi), compare_rfi_numobs); printf("\n Ten most numerous birdies:\n"); printf("# Number Period(ms) Freq(Hz) Sigma \n"); printf("----------------------------------------------------\n"); for (ii = 0; ii < 10; ii++) { double pperr; char temp1[40], temp2[40]; if (rfivect[ii].freq_var == 0.0) { pperr = 0.0; sprintf(temp1, " %-14g", rfivect[ii].freq_avg); sprintf(temp2, " %-14g", 1000.0 / rfivect[ii].freq_avg); } else { pperr = 1000.0 * sqrt(rfivect[ii].freq_var) / (rfivect[ii].freq_avg * rfivect[ii].freq_avg); nice_output_2(temp1, rfivect[ii].freq_avg, sqrt(rfivect[ii].freq_var), -15); nice_output_2(temp2, 1000.0 / rfivect[ii].freq_avg, pperr, -15); } printf("%-2d %-8d %13s %13s %-8.2f\n", ii + 1, rfivect[ii].numobs, temp2, temp1, rfivect[ii].sigma_avg); } printf("\nDone.\n\n"); } /* Close the files and cleanup */ free_rfi_vector(rfivect, numrfivect); free_mask(newmask); if (cmd->maskfileP) free_mask(oldmask); free(outfilenm); free(statsfilenm); free(bytemaskfilenm); free(maskfilenm); free(rfifilenm); vect_free(dataavg[0]); vect_free(dataavg); vect_free(datastd[0]); vect_free(datastd); vect_free(datapow[0]); vect_free(datapow); vect_free(bytemask[0]); vect_free(bytemask); if (!cmd->nocomputeP) { // Close all the raw files and free their vectors close_rawfiles(&s); vect_free(chandata); if (insubs) vect_free(srawdata); else vect_free(rawdata); } return (0); }
//------------------------------------------------------ Fonctions privées static facteur * get_prime_factors ( uint64_t nombre ) // Mode d'emploi : // Calcule les facteurs premiers du nombre passé en paramètre et les stocke // dans la structure de données. // Algorithme : // Si le nombre demandé, aucun calcul n'est fait. // Si le nombre demandé n'est pas présent, on lui cherche un facteur. Dès qu'un // facteur est trouvé, on appelle cette fonction récursivement pour le nombre // divisé par ce diviseur. Au retour, on insère une nouvelle feuille dans // l'arbre. { facteur * retour; if ( Search ( nombre, &retour ) == 0 ) { //Le nombre est connu ! //printf( "Nombre Connu : %" PRIu64 "\n", nombre ); return retour; } else { //Il faut trouver un facteur au nombre facteur * retour; facteur * nouvelleFeuille; if ( nombre % 2 == 0 ) { retour = get_prime_factors ( nombre / 2 ); nouvelleFeuille = Init ( ); nouvelleFeuille->nombre = nombre; nouvelleFeuille->diviseur = 2; nouvelleFeuille->facteur = retour; Insert ( nouvelleFeuille, racine ); return nouvelleFeuille; } if ( nombre % 3 == 0 ) { retour = get_prime_factors ( nombre / 3 ); nouvelleFeuille = Init ( ); nouvelleFeuille->nombre = nombre; nouvelleFeuille->diviseur = 3; nouvelleFeuille->facteur = retour; Insert ( nouvelleFeuille, racine ); return nouvelleFeuille; } uint64_t i = 5; uint64_t inc = 4; while ( i * i < nombre ) { if ( nombre%i == 0 ) { nouvelleFeuille = Init ( ); retour = get_prime_factors ( nombre / i ); //Appel récursif nouvelleFeuille->facteur = retour; nouvelleFeuille->nombre = nombre; nouvelleFeuille->diviseur = i; Insert ( nouvelleFeuille, racine ); return nouvelleFeuille; } else { inc = 6 - inc; i+= inc; } }//-- fin while //On est sorti de la boucle -> nombre est nécessairement premier nouvelleFeuille = Init ( ); nouvelleFeuille->nombre = nombre; nouvelleFeuille->diviseur = nombre; Insert ( nouvelleFeuille, racine ); return nouvelleFeuille; } }