IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Téléchargé 1 fois
Vote des utilisateurs
0 
0 
Détails
Éditeur : cabviva
Licence : Libre
Mise en ligne le 20 février 2018
Langue : Français
Référencé dans
Navigation

classnph

, deux codes = Une solution

Typage du nombre entier :
- Réponse qualifiant le nombre ( pair, impair)
Type = Reste = nombre%6
Essayage du nombre premier :
- Réponse quantitative du nombre ( quotient)
Intervalle = Quotient = 1/nombre

[http://www.developpez.net/forums/blogs/307889-toumic/b1554/facons-traiter-nombres-premiers-multiples/]
[http://www.cabviva.com/agenph.html]
Merci vinss pour les commentaires qui m'ont aidés à me souvenir de la commutativité, et du carré
Merci biBistouille par son champ d'activité, qui a propulsé une méthode remarquablement technique
Pour le fun, un exemple gradé :)
Cosmic 513974268
ip 11 dvs 513974268 sq3 150 sq4 12
eleme 12 typ 0 sqrip 22671
1 * 513974268 typ 1*0
2 * 256987134 typ 2*0
3 * 171324756 typ 3*0
4 * 128493567 typ 4*3
6 * 85662378 typ 0*0
9 * 57108252 typ 3*0 A3*6 A12*A4759021*
12 * 42831189 typ 0*3 A0*3 A9*A4759021*
18 * 28554126 typ 0*0
27 * 19036084 typ 3*4
36 * 14277063 typ 0*3
54 * 9518042 typ 0*2
108 * 4759021 typ 0*1 A108*B4759021*
nphb_6b7corrige.py En : 0.03610491752624512

Et, son sous-multiple favori :)
Cosmic 108
ip 2 dvs 108 sq3 3 sq4 1
eleme 6 typ 0 sqrip 10
1 * 108 typ 1*0
2 * 54 typ 2*0
3 * 36 typ 3*0
4 * 27 typ 4*3
6 * 18 typ 0*0
9 * 12 typ 3*0
nphb_6b7corrige.py En : 0.029962539672851562

NPHony_1a.py:
Simplifié
nphysic_1.py. Cause à causés...
Nombres Premiers :ip: [1, 3, 11, 101]
1 * 9999876543210000123456789999 typ 1*3
3 * 3333292181070000041152263333 typ 3*3
9 * 1111097393690000013717421111 typ 3*1
11 * 909079685746363647586980909 typ 5*3
33 * 303026561915454549195660303 typ 3*3
99 * 101008853971818183065220101 typ 3*5
101 * 99008678645643565578780099 typ 5*3
303 * 33002892881881188526260033 typ 3*3
909 * 11000964293960396175420011 typ 3*5
1111 * 9000788967785778688980009 typ 1*3
3333 * 3000262989261926229660003 typ 3*3
9999 * 1000087663087308743220001 typ 3*1
Cosmic 9999876543210000123456789999 typ 3 long 12
nphysic_11a.py En 7.668458700180054
Ce difficile sujet et la cause des nombres aux communautés différentes, la maitrise du code chargé de leurs développements est ainsi rendue presque impossible à défaut de connaître les communs avant analyse...


Un pas de plus grâce à la production communale des nombres premiers et de leurs systématiques : PC9co.py (balle)
Dire que le sujet a une fin est une affirmation peu sûre, selon que les méthodes bien que distinctes permettent de nombreuses modulations. Puisque révéler les associations des nombres premiers multiples et communs, ne s'arrête pas à une unique application. Si le monde que je connais n'a pas vraiment une idée précise sur une autre utilité, celui des tiers a peut être différentes solutions... Devant cet éternel mystérieux et long nombre premier à décrypter à la mode de chez nous, soit rapidement avant la fin du monde :)
Avatar de VinsS
Expert éminent https://www.developpez.com
Le 02/08/2016 à 10:24
Et ceci:
Code : Sélectionner tout
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import time
from math import sqrt
num = 1626
sqr = int(sqrt(num)) + 1

def toumic(tot):
    begin = time.time()
    for i in range(tot):
        for y in range(tot):
            iy = i * y
            if iy == tot:
                print("%s * %s = %s" % (i, y, tot))
    print("Done at: %s" %(time.time() - begin))

def vinss(tot, max_):
    begin = time.time()
    for i in range(max_):
        for y in range(max_, tot):
            if i * y == tot:
                print("%s * %s = %s" % (i, y, tot))
    print("Done at: %s" %(time.time() - begin))

toumic(num)
vinss(num, sqr)
Code : Sélectionner tout
1
2
3
4
5
6
7
8
9
10
11
12
2 * 813 = 1626
3 * 542 = 1626
6 * 271 = 1626
271 * 6 = 1626
542 * 3 = 1626
813 * 2 = 1626
Done at: 0.7460360527038574
2 * 813 = 1626
3 * 542 = 1626
6 * 271 = 1626
Done at: 0.017701148986816406
Avatar de
https://www.developpez.com
Le 03/07/2017 à 21:34
Citation Envoyé par bistouille Voir le message
Salut toumic,
(le comique psychédélique du monde quantique de la musique, ah les musicos sont parfois bien barrés )

Blague à part,

Tu pourrais mettre des commentaires dans ton script ?
Histoire qu'on en comprenne le cheminement, car pas facile de suivre ton raisonnement sans un minimum d'explications.

Ah aussi quelques variables qui servent pas.
Quote bistouille
Après corrections et commentaires sur le vif du programme, un résultat qui sera suivit ultérieurement d'explications sommaires.

Code : Sélectionner tout
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
#!/usr/bin/env python3.6
# -*- coding: utf-8 -*-
# Série communs. En Général Python
# Version : Tierse facture
import time
import copy
"""MusicAToumic En"""
# Programme       nphysic_2a : 28 juin 2017
# Programme        nphysic_3 : 28 juin 2017
# Programme        nphysic_4 : 3 juillet 2017
"""Découvrir les multiples d'un NOMBRE
1- Tableau(imem[NP]) des :ip;dv: de type (1, 5)
2- Copie (imem) sur tableau(itab)
3- Boucle (imem) sur (itab)
4- :ion1::ion2: Motif de progression
5- Modélisation :ip:
6- :print: Points d'analyses
Typogramme nucloïde
P = Points d'itérations 'u15171w-14925...'
NP = Nombre Pemier: Signé '°'
NpP = Nombre préalable Premier: Types '1&5'
NpPip = Tableau :imem[ip(NP)]: Résultat "ip"
NpPdv = Tableau :imem[dv(NP)]: Résultat "ip"
NC = Nombre Commun :itab[NC]: Résultat "ip"
Les premiers tempéraments préalables NpP '1&5'
Fonction :imemap: Nombres Premiers NP
Les multiplications NP produisent NC
Mes premiers pas sur sur cette échelle
"""
dod0 = time.time()

def onuno(uno):
    """ Pour un nombre :uno:
    À la recherche des sous-multiples
    """
    u1 = 0
    if uno == 0:  # :uno=0: Zéro issue
        uno = 1
        u1 = 1
    uo5 = int(uno ** .5)
    uo6 = uno % 6
    u25 = int(uno ** .25)
    iut = ((uo5 - u25) // 2)
    print('uo5(v):', uo5, 'u25(w,x):', u25, 'iut(y,z):', iut)
    # Tableau :imem[ip(NP)]:
    imem = []
    v = uo5  # :uo5: Racine(uno)
    w = x = u25  # :u25: Racine(uo5)
    if iut > u25:  # Si oui: Commence à 1
        u = 1
    else:  # Si non: Commence à 2. Sinon ERREUR
        u = 2
    y = z = iut  # Entre :uo5: et :u25:
    v_ = w_ = z_ = 0  # Indices des fins (v_ pour v...)
    if u1 == 0:  # Zéro issue
        # Fonction d'appel à condition NP
        def imemap(uz):
            """ Les nombres premiers NP
            Des préalables premiers :uz: déjà '1&5' """
            # Condition du niveau bas (1, 2, 3, 4, 5, 6, 7)
            if not uno % uz and uz % 6 in (1, 3, 5) \
               and uz < 8:
                imem.append(uz)  # Tableau :imem[ip(NP)]:
            else:
                # Rapports des racines carrées :uz:
                sq5 = int(uz ** .5)
                sq2 = int(uz ** .25)
                i0 = (sq5 - sq2) // 2  # Entre :sq2: et :sq5:
                # :iep: Ordonnée de carré à carré²
                q = 0
                for iep in range(sq5, i0, -1):
                    if not uz % iep \
                       and iep % 6 in (1, 5):
                        break
                    o = sq2 + q  # Ordonnée de carré² incrémenté
                    if not uz % o \
                       and o % 6 in (1, 5):
                        break
                    p = sq2 - q  # Ordonnée de carré² décrémenté
                    if p > 1:
                        if not uz % p \
                           and p % 6 in (1, 5):
                            break
                    q += 1
                else:  # :for: Condition vide, donc.
                    imem.append(uz)
                    # Nombre premier NP
        # À la recherche des sous-multiples
        while 1:
            # Ordonnée conditionnée aux sous-multiples
            # Condition du niveau bas (1, 2, 3, 4, 5)
            if not uno % u and u % 6 in (1, 2, 3, 5) \
               and u < 6 and u not in imem:
                imem.append(u)  # Tableau :imem[ip(NP)]:
            if v > y - 1 and v_ == 0:  # Si oui: Faire
                if not uno % v and v not in imem:
                    if v % 6 in (1, 5):  # NpP :v: est de type '1&5'
                        imemap(v)  # Appel :imemap: Sortant :v: NpP
                    elif v == uo5:  # Le carré est rencontré
                        imemap(v)
                if y % 6 in (1, 5) \
                   and not uno % y \
                   and y not in imem:  # y = iut(+1)
                    imemap(y)
                # :uo6=uno%6: Aléa type NpP test dv
                # NpPdv = Tableau :imem[dv(NP)]:
                if uo6 in (1, 5) and iut != 0:  # Si oui: Faire
                    if (uno // v) % 6 in (1, 5) \
                       and v not in imem \
                       and not uno % (uno // v):
                        imemap(v)  # Appel :imemap: Sortant :v: NpP
                    if (uno // y) % 6 in (1, 5) \
                       and y not in imem \
                       and not uno % (uno // y):
                        imemap(y)
            else:  # Si non: Indice terminal
                v_ = 1
            if w > u - 1 and w_ == 0:  # Si oui: Faire
                if not uno % w \
                   and w % 6 in (1, 5) \
                   and w not in imem:  # w = u25(-1)
                    imemap(w)  # Appel :imemap: Sortant :w: NpP
                if not uno % u and u % 6 in (1, 5) \
                   and u not in imem \
                   and u > 1:  # u = u(+1)
                    imemap(u)
                # :uo6=uno%6: Aléa type NpP test dv
                # NpPdv = Tableau :imem[dv(NP)]:
                if uo6 in (1, 5) and iut != 0:  # Si oui: Faire
                    if (uno // w) % 6 in (1, 5) \
                       and w not in imem \
                       and not uno % (uno // w):
                        imemap(w)  # Appel :imemap: Sortant :w: NpP
                    if (uno // u) % 6 in (1, 5) \
                       and u not in imem \
                       and not uno % (uno // u):
                        imemap(u)
            else:  # Si non: Indice terminal
                w_ = 1
            if z > x - 1 and z_ == 0:  # Si oui: Faire
                if not uno % z \
                   and z % 6 in (1, 5) \
                   and z not in imem:  # z = iut(-1)
                    imemap(z)
                if not uno % x and x % 6 in (1, 5) \
                   and x not in imem:  # x = u25(+1)
                    imemap(x)
                # :uo6=uno%6: Aléa type NpP test dv
                # NpPdv = Tableau :imem[dv(NP)]:
                if uo6 in (1, 5) and iut != 0:  # Si oui: Faire
                    if (uno // z) % 6 in (1, 5) \
                       and z not in imem \
                       and not uno % (uno // z):
                        imemap(z)  # Appel :imemap: Sortant :z: NpP
                    if (uno // x) % 6 in (1, 5) \
                       and x not in imem \
                       and not uno % (uno // x):
                        imemap(x)
            else:  # Si non: Indice terminal
                z_ = 1
            # Ordonnées positives et négatives
            if v_ == 0:
                v -= 1
                y += 1
            if w_ == 0:
                w -= 1
                u += 1
            if z_ == 0:
                z -= 1
                x += 1
            vwz = v_ + w_ + z_  # :vwz: Cumul des terminaux
            if vwz > 2:  # :vwz=3: Le tour est fait !
                break
    # Tableau :imem[ip(NP)]: Trier
    imem.sort()
    # 2- Copie (imem) sur tableau(itab)
    itab = copy.copy(imem)
    print('Nombres Premiers :ip:', imem)  # Affiche (les) NP
    if u1 == 0:  # Zéro issue
        # Les multiplications NP produisent NC
        while 1:
            ion1 = len(itab)
            for i in imem:
                for y in itab:
                    i1 = y * i
                    if i1 not in itab \
                       and not uno % i1:
                        itab.append(i1)
                        # NC = Nombre Commun :itab[NC]: Résultat "ip"
            itab.sort()
            ion2 = len(itab)
            if ion1 == ion2: # 4- :ion1::ion2: Motif de progression
                break
        for i in itab:  # Démultiplier :i: produire :d:
            d = uno // i
            ip, dv = i, d
            if ip < dv or ip == dv:  # Déblocage :uno = 2 ou 4:
                print('%s * %s  typ %s*%s' % (ip, dv, ip % 6, dv % 6))
    else:
        # Zéro issue :uno;onu:
        print('%s * %s  typ %s*%s' % (uno, onu, uno % 6, onu % 6))
        uno = 0
    print('Cosmic', uno, 'typ', uo6, 'long', len(itab))
    print('nphysic_4.py En {}'.format(time.time() - dod0))

# Nombre original :onu:
onu = 987654321
onuno(onu)
# nombre(onu): Charge zéro
# nombre(uno): Charge unité
J'ai rencontré un problème avec le nombre initial (12345678994), que j'ai solutionné, en ajoutant çà
Code : Sélectionner tout
if o > 1:
là où il faut. En imitant cet existant
Code : Sélectionner tout
if p > 1:
Code : Sélectionner tout
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
#!/usr/bin/env python3.6
# -*- coding: utf-8 -*-
# Série communs. En Général Python
# Version : Tierse facture
import time
import copy
"""MusicAToumic En"""
# Programme       nphysic_2a : 28 juin 2017
# Programme        nphysic_3 : 28 juin 2017
# Programme       nphysic_4a : 3 juillet 2017
"""Découvrir les multiples d'un NOMBRE
1- Tableau(imem[NP]) des :ip;dv: de type (1, 5)
2- Copie (imem) sur tableau(itab)
3- Boucle (imem) sur (itab)
4- :ion1::ion2: Motif de progression
5- Modélisation :ip:
6- :print: Points d'analyses
Typogramme nucloïde
P = Points d'itérations 'u15171w-14925...'
NP = Nombre Pemier: Signé '°'
NpP = Nombre préalable Premier: Types '1&5'
NpPip = Tableau :imem[ip(NP)]: Résultat "ip"
NpPdv = Tableau :imem[dv(NP)]: Résultat "ip"
NC = Nombre Commun :itab[NC]: Résultat "ip"
Les premiers tempéraments préalables NpP '1&5'
Fonction :imemap: Nombres Premiers NP
Les multiplications NP produisent NC
Mes premiers pas sur sur cette échelle
"""
dod0 = time.time()

def onuno(uno):
    """ Pour un nombre :uno:
    À la recherche des sous-multiples
    """
    u1 = 0
    if uno == 0:  # :uno=0: Zéro issue
        uno = 1
        u1 = 1
    uo5 = int(uno ** .5)
    uo6 = uno % 6
    u25 = int(uno ** .25)
    iut = ((uo5 - u25) // 2)
    print('uo5(v):', uo5, 'u25(w,x):', u25, 'iut(y,z):', iut)
    # Tableau :imem[ip(NP)]:
    imem = []
    v = uo5  # :uo5: Racine(uno)
    w = x = u25  # :u25: Racine(uo5)
    if iut > u25:  # Si oui: Commence à 1
        u = 1
    else:  # Si non: Commence à 2. Sinon ERREUR
        u = 2
    y = z = iut  # Entre :uo5: et :u25:
    v_ = w_ = z_ = 0  # Indices des fins (v_ pour v...)
    if u1 == 0:  # Zéro issue
        # Fonction d'appel à condition NP
        def imemap(uz):
            """ Les nombres premiers NP
            Des préalables premiers :uz: déjà '1&5' """
            # Condition du niveau bas (1, 2, 3, 4, 5, 6, 7)
            if not uno % uz and uz % 6 in (1, 3, 5) \
               and uz < 8:
                imem.append(uz)  # Tableau :imem[ip(NP)]:
            else:
                # Rapports des racines carrées :uz:
                sq5 = int(uz ** .5)
                sq2 = int(uz ** .25)
                i0 = (sq5 - sq2) // 2  # Entre :sq2: et :sq5:
                # :iep: Ordonnée de carré à carré²
                q = 0
                for iep in range(sq5, i0, -1):
                    if not uz % iep \
                       and iep % 6 in (1, 5):
                        break
                    o = sq2 + q  # Ordonnée de carré² incrémenté
                    if o > 1:
                        if not uz % o \
                           and o % 6 in (1, 5):
                            break
                    p = sq2 - q  # Ordonnée de carré² décrémenté
                    if p > 1:
                        if not uz % p \
                           and p % 6 in (1, 5):
                            break
                    q += 1
                else:  # :for: Condition vide, donc.
                    imem.append(uz)
                    # Nombre premier NP
        # À la recherche des sous-multiples
        while 1:
            # Ordonnée conditionnée aux sous-multiples
            # Condition du niveau bas (1, 2, 3, 4, 5)
            if not uno % u and u % 6 in (1, 2, 3, 5) \
               and u < 6 and u not in imem:
                imem.append(u)  # Tableau :imem[ip(NP)]:
            if v > y - 1 and v_ == 0:  # Si oui: Faire
                if not uno % v and v not in imem:
                    if v % 6 in (1, 5):  # NpP :v: est de type '1&5'
                        imemap(v)  # Appel :imemap: Sortant :v: NpP
                    elif v == uo5:  # Le carré est rencontré
                        imemap(v)
                if y % 6 in (1, 5) \
                   and not uno % y \
                   and y not in imem:  # y = iut(+1)
                    imemap(y)
                # :uo6=uno%6: Aléa type NpP test dv
                # NpPdv = Tableau :imem[dv(NP)]:
                if uo6 in (1, 5) and iut != 0:  # Si oui: Faire
                    if (uno // v) % 6 in (1, 5) \
                       and v not in imem \
                       and not uno % (uno // v):
                        imemap(v)  # Appel :imemap: Sortant :v: NpP
                    if (uno // y) % 6 in (1, 5) \
                       and y not in imem \
                       and not uno % (uno // y):
                        imemap(y)
            else:  # Si non: Indice terminal
                v_ = 1
            if w > u - 1 and w_ == 0:  # Si oui: Faire
                if not uno % w \
                   and w % 6 in (1, 5) \
                   and w not in imem:  # w = u25(-1)
                    imemap(w)  # Appel :imemap: Sortant :w: NpP
                if not uno % u and u % 6 in (1, 5) \
                   and u not in imem \
                   and u > 1:  # u = u(+1)
                    imemap(u)
                # :uo6=uno%6: Aléa type NpP test dv
                # NpPdv = Tableau :imem[dv(NP)]:
                if uo6 in (1, 5) and iut != 0:  # Si oui: Faire
                    if (uno // w) % 6 in (1, 5) \
                       and w not in imem \
                       and not uno % (uno // w):
                        imemap(w)  # Appel :imemap: Sortant :w: NpP
                    if (uno // u) % 6 in (1, 5) \
                       and u not in imem \
                       and not uno % (uno // u):
                        imemap(u)
            else:  # Si non: Indice terminal
                w_ = 1
            if z > x - 1 and z_ == 0:  # Si oui: Faire
                if not uno % z \
                   and z % 6 in (1, 5) \
                   and z not in imem:  # z = iut(-1)
                    imemap(z)
                if not uno % x and x % 6 in (1, 5) \
                   and x not in imem:  # x = u25(+1)
                    imemap(x)
                # :uo6=uno%6: Aléa type NpP test dv
                # NpPdv = Tableau :imem[dv(NP)]:
                if uo6 in (1, 5) and iut != 0:  # Si oui: Faire
                    if (uno // z) % 6 in (1, 5) \
                       and z not in imem \
                       and not uno % (uno // z):
                        imemap(z)  # Appel :imemap: Sortant :z: NpP
                    if (uno // x) % 6 in (1, 5) \
                       and x not in imem \
                       and not uno % (uno // x):
                        imemap(x)
            else:  # Si non: Indice terminal
                z_ = 1
            # Ordonnées positives et négatives
            if v_ == 0:
                v -= 1
                y += 1
            if w_ == 0:
                w -= 1
                u += 1
            if z_ == 0:
                z -= 1
                x += 1
            vwz = v_ + w_ + z_  # :vwz: Cumul des terminaux
            if vwz > 2:  # :vwz=3: Le tour est fait !
                break
    # Tableau :imem[ip(NP)]: Trier
    imem.sort()
    # 2- Copie (imem) sur tableau(itab)
    itab = copy.copy(imem)
    print('Nombres Premiers :ip:', imem)  # Affiche (les) NP
    if u1 == 0:  # Zéro issue
        # Les multiplications NP produisent NC
        while 1:
            ion1 = len(itab)
            for i in imem:
                for y in itab:
                    i1 = y * i
                    if i1 not in itab \
                       and not uno % i1:
                        itab.append(i1)
                        # NC = Nombre Commun :itab[NC]: Résultat "ip"
            itab.sort()
            ion2 = len(itab)
            if ion1 == ion2: # 4- :ion1::ion2: Motif de progression
                break
        for i in itab:  # Démultiplier :i: produire :d:
            d = uno // i
            ip, dv = i, d
            if ip < dv or ip == dv:  # Déblocage :uno = 2 ou 4:
                print('%s * %s  typ %s*%s' % (ip, dv, ip % 6, dv % 6))
    else:
        # Zéro issue :uno;onu:
        print('%s * %s  typ %s*%s' % (uno, onu, uno % 6, onu % 6))
        uno = 0
    print('Cosmic', uno, 'typ', uo6, 'long', len(itab))
    print('nphysic_4a.py En {}'.format(time.time() - dod0))

# Nombre original :onu:
onu = 365212345677
onuno(onu)
# nombre(onu): Charge zéro
# nombre(uno): Charge unité
Avatar de forum
Robot Forum https://www.developpez.com
Le 31/07/2016 à 12:31
Bonjour,

Je vous propose un nouvel élément à utiliser : classnph

, deux codes = Une solution

Typage du nombre entier :

- Réponse qualifiant le nombre ( pair, impair)

Type = Reste = nombre%6

Essayage du nombre premier :

- Réponse quantitative du nombre ( quotient)

Intervalle = Quotient = 1/nombre

Qu'en pensez-vous ?
Avatar de
https://www.developpez.com
Le 01/08/2016 à 21:02

Code : Sélectionner tout
1
2
3
4
5
6
7
8
# Affiche La Multiplication
nombre = 1626
for i in range(1, nombre):
    for y in range(1, nombre):
        iy = i * y
        if iy == nombre:
            print(i, '*', y, '=', iy)
.../
Avatar de
https://www.developpez.com
Le 03/08/2016 à 21:29
Ou bien
Code : Sélectionner tout
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# !/usr/bin/env python 3.5
# -*- coding: utf-8 -*-
import time
from math import sqrt
num = 9
sqr = int(sqrt(num))
print(sqr)
 
def toumic(tot):
    begin = time.time()
    for i in range(tot):
        for y in range(tot):
            iy = i * y
            if iy == tot:
                print("toumic = %s * %s = %s" % (i, y, tot))
    print("toumic = Done at: %s" %(time.time() - begin))
 
def vinss(tot, max_):
    begin = time.time()
    for i in range(max_):
        for y in range(max_, tot):
            if i * y == tot:
                print("vinss = %s * %s = %s" % (i, y, tot))
    print("vinss = Done at: %s" %(time.time() - begin))
 
toumic(num)
vinss(num, sqr + 1)
Code : Sélectionner tout
1
2
3
4
5
3
toumic = 3 * 3 = 9
toumic = Done at: 0.0
vinss = Done at: 0.0
Avatar de
https://www.developpez.com
Le 04/08/2016 à 19:30
Citation Envoyé par toumic Voir le message
Ou bien
Code : Sélectionner tout
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# !/usr/bin/env python 3.5
# -*- coding: utf-8 -*-
import time
from math import sqrt
num = 9
sqr = int(sqrt(num))
print(sqr)
 
def toumic(tot):
    begin = time.time()
    for i in range(tot):
        for y in range(tot):
            iy = i * y
            if iy == tot:
                print("toumic = %s * %s = %s" % (i, y, tot))
    print("toumic = Done at: %s" %(time.time() - begin))
 
def vinss(tot, max_):
    begin = time.time()
    for i in range(max_):
        for y in range(max_, tot):
            if i * y == tot:
                print("vinss = %s * %s = %s" % (i, y, tot))
    print("vinss = Done at: %s" %(time.time() - begin))
 
toumic(num)
vinss(num, sqr + 1)
Code : Sélectionner tout
1
2
3
4
5
3
toumic = 3 * 3 = 9
toumic = Done at: 0.0
vinss = Done at: 0.0
Une toute petite correction pour un résultat pour tous

Code : Sélectionner tout
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# !/usr/bin/env python 3.5
# -*- coding: utf-8 -*-
import time
from math import sqrt
num = 1600
sqr = int(sqrt(num))
print(sqr)
 
def toumic(tot):
    begin = time.time()
    for i in range(tot):
        for y in range(tot):
            if i * y == tot:
                print("toumic = %s * %s = %s" % (i, y, tot))
    print("toumic = Done at: %s" %(time.time() - begin))
 
def vinss(tot, max_):
    begin = time.time()
    for i in range(max_):
        for y in range(max_ - 1, tot):
            if i * y == tot:
                print("vinss = %s * %s = %s" % (i, y, tot))
    print("vinss = Done at: %s" %(time.time() - begin))
 
toumic(num)
vinss(num, sqr + 1)
labowagenph\agenph1toast2et.py ================
4
toumic = 2 * 8 = 16
toumic = 4 * 4 = 16
toumic = 8 * 2 = 16
toumic = Done at: 0.008025884628295898
vinss = 2 * 8 = 16
vinss = 4 * 4 = 16
vinss = Done at: 0.00871419906616211
>>>
Code : Sélectionner tout
1
2
# Raté mais c'est pas grave :)
Avatar de
https://www.developpez.com
Le 12/10/2016 à 19:10
Citation Envoyé par bistouille  Voir le message
Allez parce que ça m'amuse aussi les concours de celui qui pisse (du code) le plus loin

.../...

Code : Sélectionner tout
1
2
splash@splash:~$ py3 toumic_est_trop_comique.py  
40

Et plus petite, p...

Code : Sélectionner tout
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
 
import time 
from math import sqrt 
num = 1600 
sqr = int(sqrt(num)) 
  
def toumic(tot): 
    begin = time.time() 
    for i in range(sqr + 1): 
        for y in range(sqr, int(num/2)+1): 
            if i * y == tot: 
                print("toumic = %s * %s = %s" % (i, y, tot)) 
                break 
    print("toumic = Done at: %s" %(time.time() - begin)) 
  
def biBistouille(num) : 
    debut = time.time() 
    num2 = num 
    def genInfini(i, pas) : 
        while i < float('inf') : 
            yield(i) 
            i += pas 
  
    def genPrems() : 
        yield 2 
        for n in genInfini(2, 1) : 
            if not n % 2 : 
                continue 
            x = 3 
            p = True 
            while x < n**0.5 + 1 : 
                if not n % x : 
                    p = False 
                    break 
                x += 2 
            if not p : 
                continue 
            yield n 
  
    gp = genPrems() 
    liste = [] 
    while num2 > 1 : 
        np = next(gp) 
        while not num2 % np : 
            liste.append(np) 
            num2 /= np 
  
    i = 0 
    comb = set() 
    while i < len(liste) : 
        comb.add((liste[i], int(num / liste[i]))) 
        z = liste[i] 
        for n in liste[:i] : 
            z *= n 
            res = int(num / z) 
            valeur = (z, res) if z < res else (res, z) 
            comb.add(valeur) 
        i += 1 
  
    res = '' 
    for n in sorted(comb) : 
        res += 'BiBistouille : {} * {} = {}\n'.format(n[0], n[1], num) 
    print('{}Bibistouille Effectué en : {}'.format(res, time.time() - debut)) 
  
# num = 1600 
toumic(num) 
biBistouille(num)
Avatar de
https://www.developpez.com
Le 05/11/2016 à 19:55
Re-salut
Je relance les dés ...

Code : Sélectionner tout
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
 
import time 
from math import sqrt 
  
def biBistouille(num) : 
    debut = time.time() 
    num2 = num 
    def genInfini(i, pas) : 
        while i < float('inf') : 
            yield(i) 
            i += pas 
  
    def genPrems() : 
        yield 2 
        for n in genInfini(2, 1) : 
            if not n % 2 : 
                continue 
            x = 3 
            p = True 
            while x < n**0.5 + 1 : 
                if not n % x : 
                    p = False 
                    break 
                x += 2 
            if not p : 
                continue 
            yield n 
  
    gp = genPrems() 
    liste = [] 
    while num2 > 1 : 
        np = next(gp) 
        while not num2 % np : 
            liste.append(np) 
            num2 /= np 
  
    i = 0 
    comb = set() 
    while i < len(liste) : 
        comb.add((liste[i], int(num / liste[i]))) 
        z = liste[i] 
        for n in liste[:i] : 
            z *= n 
            res = int(num / z) 
            valeur = (z, res) if z < res else (res, z) 
            comb.add(valeur) 
        i += 1 
    res = '' 
    for n in sorted(comb) : 
        res += 'BiBistouille : {} * {} = {}\n'.format(n[0], n[1], num) 
    print('{}Bibistouille Effectué en : {}'.format(res, time.time() - debut)) 
 
 
def toumtoumic(num1): 
    debut2 = time.time() 
    maxinum = int(num1 / 2) 
    max = maxinum if maxinum else 1 
    min = int(sqrt(num1)) 
    def gentoum(): 
        for chnum in range(1, min + 1): 
            npnum = int(num1 / chnum) 
            if not num1 % chnum: 
                yield chnum, npnum 
            else: 
                pass 
 
    goum = gentoum() 
    for g in goum: 
        print('alpage : {} * {} = {}'.format(g[0], g[1], num1)) 
    print('toumToumic Effectué en : {}'.format(time.time() - debut2)) 
 
num = num1 = 16758984654 
biBistouille(num) 
toumtoumic(num1)
Pour un résultat gratuit

Code : Sélectionner tout
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 
 RESTART: C:\Users\Vincent\Documents\developpez\labowa\labowagenph\nphbistouille1.py  
BiBistouille : 1 * 16758984654 = 16758984654 
BiBistouille : 2 * 8379492327 = 16758984654 
BiBistouille : 3 * 5586328218 = 16758984654 
BiBistouille : 6 * 2793164109 = 16758984654 
BiBistouille : 18 * 931054703 = 16758984654 
BiBistouille : 22159 * 756306 = 16758984654 
BiBistouille : 42017 * 398862 = 16758984654 
BiBistouille : 44318 * 378153 = 16758984654 
BiBistouille : 66477 * 252102 = 16758984654 
BiBistouille : 84034 * 199431 = 16758984654 
BiBistouille : 126051 * 132954 = 16758984654 
Bibistouille Effectué en : 0.27219223976135254 
alpage : 1 * 16758984654 = 16758984654 
alpage : 2 * 8379492327 = 16758984654 
alpage : 3 * 5586328218 = 16758984654 
alpage : 6 * 2793164109 = 16758984654 
alpage : 9 * 1862109406 = 16758984654 
alpage : 18 * 931054703 = 16758984654 
alpage : 22159 * 756306 = 16758984654 
alpage : 42017 * 398862 = 16758984654 
alpage : 44318 * 378153 = 16758984654 
alpage : 66477 * 252102 = 16758984654 
alpage : 84034 * 199431 = 16758984654 
alpage : 126051 * 132954 = 16758984654 
toumToumic Effectué en : 0.08974242210388184 
>>>
Avatar de
https://www.developpez.com
Le 06/11/2016 à 8:05
Encore une amélioration en jeu, en copiant les techniques de l'adversaire on gagne du temps
Code : Sélectionner tout
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
 
import time 
from math import sqrt 
  
def biBistouille(num) : 
    debut = time.time() 
    num2 = num 
    def genInfini(i, pas) : 
        while i < float('inf') : 
            yield(i) 
            i += pas 
  
    def genPrems() : 
        yield 2 
        for n in genInfini(2, 1) : 
            if not n % 2 : 
                continue 
            x = 3 
            p = True 
            while x < n**0.5 + 1 : 
                if not n % x : 
                    p = False 
                    break 
                x += 2 
            if not p : 
                continue 
            yield n 
  
    gp = genPrems() 
    liste = [] 
    while num2 > 1 : 
        np = next(gp) 
        while not num2 % np : 
            liste.append(np) 
            num2 /= np 
  
    i = 0 
    comb = set() 
    while i < len(liste) : 
        comb.add((liste[i], int(num / liste[i]))) 
        z = liste[i] 
        for n in liste[:i] : 
            z *= n 
            res = int(num / z) 
            valeur = (z, res) if z < res else (res, z) 
            comb.add(valeur) 
        i += 1 
    res = '' 
    for n in sorted(comb) : 
        res += 'BiBistouille : {} * {} = {}\n'.format(n[0], n[1], num) 
    print('{}Bibistouille Effectué en : {}'.format(res, time.time() - debut)) 
 
def toumtoumic(num1): 
    debut2 = time.time() 
    min = int(sqrt(num1)) 
    def gentoum(): 
        for chnum in range(1, min + 1): 
            npnum = int(num1 / chnum) 
            if not num1 % chnum: 
                yield chnum, npnum 
            else: 
                pass 
    goum = gentoum() 
    gers = '' 
    for g in goum: 
        gers += 'alpage : {} * {} = {}\n'.format(g[0], g[1], num1) 
    print('{}toumToumic Effectué en : {}'.format(gers, time.time() - debut2)) 
 
num = num1 = 16758984654 
biBistouille(num) 
toumtoumic(num1)
Code : Sélectionner tout
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 
>>>  
========== RESTART: C:/Users/Vincent/Documents/nphbistouille3.py ========== 
BiBistouille : 1 * 16758984654 = 16758984654 
BiBistouille : 2 * 8379492327 = 16758984654 
BiBistouille : 3 * 5586328218 = 16758984654 
BiBistouille : 6 * 2793164109 = 16758984654 
BiBistouille : 18 * 931054703 = 16758984654 
BiBistouille : 22159 * 756306 = 16758984654 
BiBistouille : 42017 * 398862 = 16758984654 
BiBistouille : 44318 * 378153 = 16758984654 
BiBistouille : 66477 * 252102 = 16758984654 
BiBistouille : 84034 * 199431 = 16758984654 
BiBistouille : 126051 * 132954 = 16758984654 
Bibistouille Effectué en : 0.27670955657958984 
alpage : 1 * 16758984654 = 16758984654 
alpage : 2 * 8379492327 = 16758984654 
alpage : 3 * 5586328218 = 16758984654 
alpage : 6 * 2793164109 = 16758984654 
alpage : 9 * 1862109406 = 16758984654 
alpage : 18 * 931054703 = 16758984654 
alpage : 22159 * 756306 = 16758984654 
alpage : 42017 * 398862 = 16758984654 
alpage : 44318 * 378153 = 16758984654 
alpage : 66477 * 252102 = 16758984654 
alpage : 84034 * 199431 = 16758984654 
alpage : 126051 * 132954 = 16758984654 
toumToumic Effectué en : 0.056047677993774414 
>>>
Developpez.com décline toute responsabilité quant à l'utilisation des différents éléments téléchargés.