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 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
|
#!/usr/bin/env python3.6
# -*- coding: utf-8 -*-
# Série première. En Général Python
# Objet : Apprendre par la pratique
# MusicAtoumic nphullmen_6x Ce 11 décembre 2017
"""Pyhton Compulsion Commune"""
import time
time_ = time.time()
def zero(z):
if z == 1:
z = 0
print('Premiers (', z, ')ex\n', '[0]')
print('{} * {} Types {}&{}'
.format(z, z, z % 6, z % 6))
print('nphullmen_6x.py En: \n', time.time() - time_)
else:
print('nphullmen_6x.py En: \n', time.time() - time_)
# _____________________ 111222333222111000111222333222111
# :nombre: objet unique
nombre = 576612993639691
print('Nombre =', nombre, '; typ =', nombre % 6)
# :breakComm: printage communs
breakComm = 1
# :zero: instruction zéro
if nombre == 0:
zero(breakComm)
# :carre: service axial
carre = int(nombre ** .5)
hautniveau = [] # Liste premiers
horscourse = [] # Liste communs ip&dv
hautmulti_ = [1] # Mul.hautniveau
horsmulti_ = [1] # Mul.horscourse
c12tableau = [] # Liste communs dv
# Lecteurs initiaux
p1 = [7]
p5 = [11]
q1 = [0]
q5 = [0]
"""Borne & cartyp6
Borne : Limite en pleine forêt
Cartyp6 : Limite en plein ciel"""
cartyp6 = [carre]
borne = int(cartyp6[0] ** .992)
borne = [borne]
print('cartyp6 = %s ; borne = %s' % (cartyp6, borne))
def forme15(r1_, rng_, r6_):
"""Positionnement des Lecteurs (bas/hauts)
P1: Point (+6) Type (1)
Position inférieure :ip: Inf.carre
Q1: Point (-6) Type (5)
Position supérieure :dv: Sup.carre"""
if r6_ == 1:
if r1_ > 0:
p1[0] = rng_
else:
q1[0] = rng_
else:
dfo_ = r6_ - 1
if r1_ > 0:
p1[0] = rng_ - dfo_
else:
q1[0] = rng_ - dfo_
if r1_ > 0:
p5[0] = p1[0] - 2
else:
q5[0] = q1[0] - 2
print(' forme15 (', r1_, ') p1, typ', p1[0], p1[0] % 6)
print(' forme15 p5, typ', p5[0], p5[0] % 6)
print(' forme15 q1, typ', q1[0], q1[0] % 6)
print(' forme15 q5, typ', q5[0], q5[0] % 6)
if nombre != 0:
forme15(0, borne[0], borne[0] % 6)
def compare(c):
"""Réception et traitement (c)"""
# print('Cc', c)
hautmulti_[0] = 1
didi = [c]
if c not in horscourse:
if c > 1:
horscourse.append(c)
horscourse.sort()
sqc = int(c ** .5)
for dd in range(2, sqc):
if not c % dd:
didi.append(dd)
dddv = c // dd
didi.append(dddv)
didi.sort()
break
for di in didi:
c = di
for haut in hautniveau[1:]:
if not c % haut:
break
else:
hautniveau.append(c)
# Production haut niveau
for hha in hautniveau:
hautmulti_[0] *= hha
if hautmulti_[0] != 0:
print('C ****HAUTniveau', hautniveau)
print('C ****HAUTmulti_', hautmulti_)
for c1 in sorted(hautniveau):
for c2 in horscourse:
c12 = c1 * c2
# Séparation :carre:
if not nombre % c12 \
and c12 not in horscourse:
if c12 <= carre:
horscourse.append(c12)
horscourse.sort()
elif c12 not in c12tableau:
c12tableau.append(c12)
c12tableau.sort()
if c12tableau:
print('C max: c12 =', max(c12tableau))
for ctab in c12tableau:
iptab = nombre // ctab
# :ctab: Occurence :c12:
if iptab not in horscourse:
for hh in hautniveau[1:]:
if not iptab % hh:
break
else:
print('C c12 compare: iptab =', iptab)
compare(iptab)
if hautmulti_[0]:
c12ip = nombre // max(hautniveau)
# :c12ip: Sup.carre(dv) de Max.premier(ip)
print('C c12ip, max(c12)', c12ip, max(c12tableau))
if max(c12tableau) > c12ip:
#hautmulti_[0] = 0
print('C BREAK max(c12)', max(c12tableau))
if hautmulti_[0]:
horsmulti_[0] = 1
# Production hors course
for hho in horscourse:
if horsmulti_[0] <= nombre:
horsmulti_[0] *= hho
print('C coms(', len(horscourse), ')ex HORS(',
max(horscourse), ')')
print('C ****HORSmulti_', horsmulti_)
cartyp6[0] = int((nombre // max(hautniveau)) ** .499)
brn = int(cartyp6[0] ** .5)
borne[0] = brn
print('C cartyp6 =', cartyp6, 'borne =', borne)
# Terme commun
if max(horscourse) <= carre:
if hautmulti_[0]:
print('Cm if hautmulti', hautmulti_[0])
hdv = hautmulti_[0] * hautniveau[1]
# :hdv: Son.carre(dv) par Min.hautniveau
if hdv >= carre and not nombre % hdv:
hip = nombre // hdv
# :hip: Son(ip) du Son.carre(dv)
if hip not in horscourse:
print('Cm compare: hip =', hip)
compare(hip)
print('C')
if hautmulti_[0]:
# Termes racine
if hautmulti_[0] == nombre:
hautmulti_[0] = 0
print('E BREAK multi_==', nombre)
elif hautmulti_[0] * hautniveau[1] >= carre \
and hautmulti_[0] == max(hautniveau):
hautmulti_[0] = 0
print('E BREAK multi*min(c)', hautmulti_)
elif hautmulti_[0] * hautniveau[1] >= nombre:
hautmulti_[0] = 0
print('E BREAK multi*min(n)', hautmulti_)
elif max(horscourse) == nombre:
hautmulti_[0] = 0
print('E BREAK hors(nombre)', nombre)
else:
# Différentiel comparatif
dvinf = nombre // max(horscourse)
ipsup = dvinf // max(horscourse)
print('E nombre//max(hors) dvinf =', dvinf)
print('E dvinf//max(hors) ipsup =', ipsup)
if len(hautniveau) > 2:
typ = 0
if ipsup >= carre:
rng = int(
(nombre // max(hautniveau)) ** .4534)
r6 = rng % 6
print('E rng', rng,
'dv*.5', int(dvinf ** .499))
forme15(0, rng, r6)
else:
sqinf = int(dvinf ** .5)
print('E else(dvinf,sqinf)', dvinf, sqinf)
if not nombre % sqinf \
and sqinf % 6 in(1, 5):
print('E if(compare): sqinf =', sqinf)
compare(sqinf)
else:
sqinf = int(dvinf ** .4)
print('E sqinf', sqinf)
for e in range(2, sqinf):
if not dvinf % e:
typ = 1
if e % 6 in (1, 5) \
and e not in horscourse:
print('E for(compare): e =', e)
compare(e)
break
else:
if typ == 0 or ipsup == 1:
hautmulti_[0] = 0
print('E BREAK dvinf', dvinf)
print('E p111 multi_', p1, borne, hautmulti_[0])
wu[0] = 0
"""Bas niveau des premiers:
Création du haut niveau des nombres premiers
Lié au bas niveau des nombres premiers
Composition des hors course"""
wu = [0] # Indice d'écriture des lecteurs(1&5)
basniveau = [1, 2, 3, 5]
for i in range(1, 7):
if not nombre % i and i <= carre:
def rang(ti, i_):
if ti == 1: # Nombre Premier(basniveau)
hautniveau.append(i_)
horscourse.append(i_)
else: # Nombre Commun(basniveau)
horscourse.append(i_)
if i in basniveau:
rang(1, i)
else:
rang(2, i)
if horscourse:
for h in horscourse:
for o in horscourse:
oh = h * o
if not nombre % oh and oh not in horscourse:
print(' B compare: oh =', oh)
compare(oh)
"""Hauts niveaux premiers: cartyp6
Itérer dans l'alignement des nombres premiers
Condition évolutive des lecteurs"""
while p1[0] <= cartyp6[0]:
while wu[0] < 2: # Effet de boucle visu
print(' while P1', p1,'Q1', q1)
print(' while cartyp6', cartyp6,'borne', borne)
print(' while carre.6', int(carre ** .6),
'borne.6', int(borne[0] ** .6))
print('E')
break
if hautmulti_[0] == 0:
print(' W break hautmulti_', hautmulti_)
break
elif p1[0] > q1[0]:
print(' W break p1>q1', p1[0], q1[0])
break
elif hautmulti_[0]:
if borne[0] == int(carre ** .992):
borne[0] = int(borne[0] ** .6)
else:
borne[0] = int(carre ** .6)
if p1[0] > int(borne[0]):
print(' W break borne', p1[0], int(borne[0]))
break
# Lectures
if p1[0] == 0: # Révision nombre
print(' W P1', p1[0])
print(' W n%P1', nombre % p1[0])
if not nombre % p1[0] and p1[0] not in hautniveau \
and p1[0] not in horscourse:
print(' W p1', p1[0])
compare(p1[0])
if not nombre % p5[0] and p5[0] not in hautniveau \
and p5[0] not in horscourse:
print(' W p5', p5[0])
compare(p5[0])
if not nombre % q1[0] and q1[0] not in hautniveau \
and q1[0] not in horscourse:
print(' W q1', q1[0])
compare(q1[0])
if not nombre % q5[0] and q5[0] not in hautniveau \
and q5[0] not in horscourse:
print(' W q5', q5[0])
compare(q5[0])
p1[0] += 6
p5[0] += 6
q1[0] -= 6
q5[0] -= 6
wu[0] += 1
if nombre != 0:
"""Désigne la communauté:
Les nombres premiers associés :hautniveau:
Produisent la communauté des multiples communs"""
if max(horscourse) > carre:
hi = len(horscourse) // 2
else:
hi = len(horscourse)
hautniveau.sort()
print('carre %s cartyp6 %s borne %s' % (carre, cartyp6, borne))
print('Premiers (', hi, ')ex\n', hautniveau)
for i in sorted(horscourse):
if breakComm == 0:
ha = horscourse[hi - 1]
hu = horscourse[0]
print('Duos (inf)*(sup)|(sup)*(inf) \n {} * {} Types {}&{}'
.format(hu, nombre // hu, hu % 6, (nombre // hu) % 6))
print(' {} * {} Types {}&{}'
.format(ha, nombre // ha, ha % 6, (nombre // ha) % 6))
break
else:
print('{} * {} Types {}&{}'
.format(i, nombre // i, i % 6, (nombre // i) % 6))
print('nphullmen_6x.py En: \n', time.time() - time_)
print('', ) |
Partager