Logique
Boucles
Math
Texte
Listes
Données
Variables
Fonctions
Programmation
p5.js
Objets web
Propriétés
Formes
Tortue
Apparence
GeoGebra
var etapeFacto, facto, p, np, mult, n, nombres, factorisations, i, canevas, formatNombres, formatFactorisations, tableau, text, nEstPremier; /** * Décrire cette fonction… */ function actions_initiales() { document.body.style.paddingLeft="40px"; createElement("h1",'Factorisation première'); nombres = ['Nombre']; factorisations = ['Factorisation']; for (i = 2; i <= 1000; i += abs(1)) { nombres.push(i); factorisations.push((codeMath((factoriser(i))))); } tableau=creerAffichageListes([nombres, factorisations],300,"PIXELS","ACTIVEE",700,24); refreshMathJax();} /** * Décrire cette fonction… */ function actions_en_boucle() { } /** * Décrire cette fonction… */ function factoriser(n) { nEstPremier = true; etapeFacto = 0; facto = ''; p = 2; np = 0; mult = ''; while (n > 1) { if (n % p == 0) { while (n % p == 0) { np = np + 1; n = n / p; } if (np == 1) { facto = [facto,mult,p].join(''); if (n != 1) { nEstPremier = false; } } else { facto = [facto,mult,p,'^(',np,')'].join(''); nEstPremier = false; } mult = '×'; } p = p + 1; np = 0; } return facto; }