Précédent
- 1
- 2
-
1 équation à 20 inconnues... votre résultat confirme ce que je disais sur une infinité de solutions ;) En ne gardant que les nombres entiers, effectivment il doit y en avoir un nombre fini, mais bonne chance quand même pour la quantité !
-
Bonsoir,
pour tes coefficients, ça donne :
niveaux traités :___Nb_____durée___Nb solutions___Nb combinaisons
_____20 à 7_____14______8mn_______149________147 253
_____20 à 6_____15_____31mn_______649 ________579 436
_____20 à 5_____16___1h43mn______2,832_______2 343 533
voici le code :
(je précise que je n'ai pas fait dans la dentelle)
Sur une feuille, mettre en A1:T1 et A4:T4 les libellés I01 --> I20 pour rendre lisible l'affichage des résultats.
Puis, lancer la macro une_équation_20_inconnues()
Sub une_équation_20_inconnues() result = 13378 C01 = 80: I01 = 0: C02 = 148: I02 = 0 C03 = 196: I03 = 0: C04 = 260: I04 = 0 C05 = 464: I05 = 0: C06 = 518: I06 = 0 C07 = 650: I07 = 0: C08 = 688: I08 = 0 C09 = 908: I09 = 0: C10 = 1326: I10 = 0 C11 = 1452: I11 = 0: C12 = 1612: I12 = 0 C13 = 1694: I13 = 0: C14 = 2040: I14 = 0 C15 = 2498: I15 = 0: C16 = 2724: I16 = 0 C17 = 5164: I17 = 0: C18 = 5180: I18 = 0 C19 = 6042: I19 = 0: C20 = 8052: I20 = 0 Som00 = 0: compteur = 0: [V3] = Now For I01 = 0 To Int((result - Som00) / C01) som01 = Som00 + I01 * C01: Cells(2, 1).Value = I01 For I02 = 0 To Int((result - Som1) / C02) Som02 = Som1 + I02 * C02: Cells(2, 2).Value = I02 For I03 = 0 To Int((result - Som02) / C03) Som03 = Som02 + I03 * C03: Cells(2, 3).Value = I03 For I04 = 0 To Int((result - Som03) / C04) Som04 = Som03 + I04 * C04: Cells(2, 4).Value = I04 For I05 = 0 To Int((result - Som04) / C05) Som05 = Som04 + I05 * C05: Cells(2, 5).Value = I05 For I06 = 0 To Int((result - Som05) / C06) Som06 = Som05 + I06 * C06: Cells(2, 6).Value = I06 For I07 = 0 To Int((result - Som06) / C07) Som07 = Som06 + I07 * C07: Cells(2, 7).Value = I07 For I08 = 0 To Int((result - Som07) / C08) Som08 = Som07 + I08 * C08: Cells(2, 8).Value = I08 For I09 = 0 To Int((result - Som08) / C09) Som09 = Som08 + I09 * C09: Cells(2, 9).Value = I09 For I10 = 0 To Int((result - Som09) / C10) Som10 = Som09 + I10 * C10: Cells(2, 10).Value = I10 For I11 = 0 To Int((result - Som10) / C11) Som11 = Som10 + I11 * C11: Cells(2, 11).Value = I11 For I12 = 0 To Int((result - Som11) / C12) Som12 = Som11 + I12 * C12: Cells(2, 12).Value = I12 For I13 = 0 To Int((result - Som12) / C13) Som13 = Som12 + I13 * C13: Cells(2, 13).Value = I13 For I14 = 0 To Int((result - Som13) / C14) Som14 = Som13 + I14 * C14: Cells(2, 14).Value = I14 For I15 = 0 To Int((result - Som14) / C15) Som15 = Som14 + I15 * C15: Cells(2, 15).Value = I15 For I16 = 0 To Int((result - Som15) / C16) Som16 = Som15 + I16 * C16: Cells(2, 16).Value = I16 For I17 = 0 To Int((result - Som16) / C17) Som17 = Som16 + I17 * C17: Cells(2, 17).Value = I17 For I18 = 0 To Int((result - Som17) / C18) Som18 = Som17 + I18 * C18: Cells(2, 18).Value = I18 For I19 = 0 To Int((result - Som18) / C19) Som19 = Som18 + I19 * C19: Cells(2, 19).Value = I19 For I20 = 0 To Int((result - Som19) / C20) som20 = Som19 + I20 * C20: Cells(2, 20).Value = I20 'If Abs(Som20 - result) / result < 0.0001 Then Call affiche(I01, I02, I03, I04, I05, I06, I07, I08, I09, I10, I11, I12, I13, I14, I15, I16, I17, I18, I19, I20,compteur) If som20 = result Then Call affiche(I01, I02, I03, I04, I05, I06, I07, I08, I09, I10, I11, I12, I13, I14, I15, I16, I17, I18, I19, I20, compteur) compteur = compteur + 1 Next I20 Next I19 Next I18 Next I17 Next I16 Next I15 Next I14 Next I13 Next I12 Next I11 Next I10 Next I09 Next I08 Next I07 Next I06 Next I05 Next I04 Next I03 Next I02 Next I01 End Sub Sub affiche(I01, I02, I03, I04, I05, I06, I07, I08, I09, I10, I11, I12, I13, I14, I15, I16, I17, I18, I19, I20, compteur) Set mapos = Range("A65000").End(xlUp).Offset(1, 0) mapos.Offset(0, 0).Value = I01: mapos.Offset(0, 1).Value = I02 mapos.Offset(0, 2).Value = I03: mapos.Offset(0, 3).Value = I04 mapos.Offset(0, 4).Value = I05: mapos.Offset(0, 5).Value = I06 mapos.Offset(0, 6).Value = I07: mapos.Offset(0, 7).Value = I08 mapos.Offset(0, 8).Value = I09: mapos.Offset(0, 9).Value = I10 mapos.Offset(0, 10).Value = I11: mapos.Offset(0, 11).Value = I12 mapos.Offset(0, 12).Value = I13: mapos.Offset(0, 13).Value = I14 mapos.Offset(0, 14).Value = I15: mapos.Offset(0, 15).Value = I16 mapos.Offset(0, 16).Value = I17: mapos.Offset(0, 17).Value = I18 mapos.Offset(0, 18).Value = I19: mapos.Offset(0, 19).Value = I20 mapos.Offset(0, 20).Value = compteur: mapos.Offset(0, 21).Value = Now End Sub -
-
Bonsoir,
un complément pour ceux que ça intéresse : en C++ le temps de traitement devient raisonnable, environ 8mn pour toutes les solutions entières
niveau 6 : Duree traitement = 0 m 0 s. Nb Solutions = 398 nb combinaisons = 365.389 niveau 5 : Duree traitement = 0 m 0 s. Nb Solutions = 1.060 nb combinaisons = 854.376 niveau 4 : Duree traitement = 0 m 0 s. Nb Solutions = 3.264 nb combinaisons = 2.392.336 niveau 3 : Duree traitement = 0 m 1 s. Nb Solutions = 9.673 nb combinaisons = 6.922.952 niveau 2 : Duree traitement = 0 m 3 s. Nb Solutions = 34.978 nb combinaisons = 23.202.170 niveau 1 : Duree traitement = 0 m 31 s. Nb Solutions = 331.138 nb combinaisons = 207.110.348 niveau 0 : Duree traitement = 8 m 25 s. Nb Solutions = 5.340.371 nb combinaisons = 3.158.498.324
Cordialement
Précédent
- 1
- 2