• Aucun résultat trouvé

if (atester

N/A
N/A
Protected

Academic year: 2022

Partager "if (atester"

Copied!
3
0
0

Texte intégral

(1)

#include <iostream>

#include <cmath>

int tabfacteurs[20000], tabpuiss[20000], tabexpo[20000] ; int prime(int atester)

{

bool pastrouve=true;

unsigned long k = 2;

if (atester == 1) return 0;

if (atester == 2) return 1;

if (atester == 3) return 1;

if (atester == 5) return 1;

if (atester == 7) return 1;

while (pastrouve) {

if ((k * k) > atester) return 1;

else

if ((atester % k) == 0) { return 0 ;

}

else k++;

} }

int main (int argc, char* argv[]) {

int i, comptelesptsfixes, nbmaxfixes, k, j, p, nbdiv, nbdivp, tempo, expo, tmp, somme, nbredondances, sommeexpo ;

bool boolpremier ;

nbmaxfixes = 0 ;

for (i=3 ; i <= 1000 ; i=i+2) //if (not(prime(i)))

{

comptelesptsfixes = 0 ;

std::cout << "\n" << i << " : \n" ; tabfacteurs[i] = 1 ;

tabpuiss[i] = 1 ; tabexpo[i] = 1 ; somme = 0 ;

tempo = i ; p = i/2 ; nbdiv = 1 ;

nbdivp = 0 ;

if (prime(tempo)) {

tabfacteurs[1] = tempo ; tabpuiss[1] = tempo ; tabexpo[1] = 1 ;

}else while ((tempo > 1) && (p > 1)) {

if ((prime(p)) && ((tempo%p) == 0)) {

tabfacteurs[nbdiv] = p ; nbdiv = nbdiv+1 ;

tempo = tempo/p ; }

p=p-1 ; }

if (not(prime(i))) nbdiv=nbdiv-1 ; if ((nbdiv == 1) && (prime(i))) {

(2)

tabpuiss[1] = i ; tabexpo[1] = 1 ; }

else if ((nbdiv == 1) && (not(prime(i)))) {

tempo = tabfacteurs[1] ; tabpuiss[1] = i ;

expo = 1 ;

while (tempo < i) {

tempo=tempo*tabfacteurs[1] ; expo = expo+1 ;

}

tabexpo[1] = expo ; }

else if (nbdiv > 1) {

for (k = 1 ; k <= nbdiv ; ++k) {

tempo = tabfacteurs[k] ; expo = 1 ;

while (((i % tempo) == 0) && (tempo < i)) {

tempo=tempo*tabfacteurs[k] ; expo = expo+1 ;

}

tabpuiss[k] = tempo/tabfacteurs[k] ; tabexpo[k] = expo-1 ;

} }

for (k = 1 ; k <= nbdiv ; ++k) {

std::cout << tabfacteurs[k] << "^" ; std::cout << tabexpo[k] << "." ; }

std::cout << "\n" ; k = 2 ;

while (k <= (i-1)/2) {

//std::cout << "j etudie " << i << "\n" ; if (((k*k)%i) == 0)

std::cout << k << " de carre nul. \n" ;

else if ((((k*k)%i) == k) || (((k*k)%i) == (i-k))) {

std::cout << k << "->" ; if ((k*k)%i < (i-1)/2) {

std::cout << "en bas (" << (k*k)/i << ") " ; std::cout << (k*k)%i << "\n" ;

} else {

std::cout << "en haut (" << (k*k)/i << ") " ; std::cout << i-(k*k)%i << "\n" ;

}

comptelesptsfixes = comptelesptsfixes+2 ; }

k=k+1 ; }

if (comptelesptsfixes > nbmaxfixes) {

nbmaxfixes = comptelesptsfixes ;

std::cout << "le plus de pts fixes.\n" ; }

(3)

} }

Références

Documents relatifs

The routine will respond by typing the contents of the location specified by the address just typed-in, and wait for another action by the operator.. The

The pertinent register contents pertaining to each type of alarm are filled in at the time an alarm occurred. If prints are needed they may be ordered at the

An alternative constilntdefln1tlon Is used for nask cnn~t;lIIt~ which IItlVfl a spccified bus source field (recall thilt the cons&#34;tnnt rnp.riury -ittldrrss is

il désignait par là Pompce qui, ayant attiré sur sa patrie ce déluge de maux, était plus propre que tout autre à trouver les moyens convenables pour s' en dé- livrer. Lorsque

Dans les espaces publics, les jardins privés, les zones résidentielles et les hôtels : habillée d'un boîtier élégant dont la forme claire et discrète fait appel aux sens,

Comme dans quelques notes récentes au sujet d’hyperboles, on s’intéresse à l’écriture des nombres comme produits de deux entiers supérieurs ou égaux à 2. La variable

tlputchar tl function' will already have been loaded and the one~ in DEFF2.CRL will be ignored... See the carrn;nts in DIO.C for canplete

the Instant-C program, the library source files, a stand-alone version of the Instant-C editor, and screen programs your keyboard for configuring PC have IBM an or compatible, if