Professional Documents
Culture Documents
Practice 6
Practice 6
La funció Fold dona l’ultim element de ”Foldlist”. Foldlist aplicat a [f,x,a,b,...] retorna
{x,f[x,a], f [ f [ x,a],b ] , ....}
Problema 2. Esbrina el significat de les funcions:
IntegerDigits[75] −→ {7, 5}
IntegerDigits[n] retorna una llista dels digits decimals de n.
IntegerDigits[75, 2] −→ {1, 0, 0, 1, 0, 1, 1}
IntegerDigits[n, b] retorna una llista en base b del digits de n.
nom95 = F old[#1 ∗ 95 + #2&, 0, {9, 8, 7, 6, 5, 4, 3, 2, 1}] −→ 60 271 701 133 691 141
IntegerDigits[nom95, 95] −→ {9, 8, 7, 6, 5, 4, 3, 2, 1}
Problema 3.
mT = ”Directory of banks in crisis” −→ ”Directory of banks in crisis”
e = 5 −→ 5
mA = T oCharacterCode[mT ] −→ {68, 105, 114, 101, 99, 116, 111, 114, 121, 32,
111, 102, 32, 98, 97, 110, 107, 115, 32, 105,
110, 32, 99, 114, 105, 115, 105, 115}
m95 = mA − 32 −→ {36, 73, 82, 69, 67, 84, 79, 82, 89, 0, 79, 70, 0, 66,
65, 78, 75, 83, 0, 73, 78, 0, 67, 82, 73, 83, 73, 83}
m10 = F old[#1 ∗ 95 + #2&, 0, m95] −→ 9 207 051 850 104 644 053 042 785 497 201 395
967 665 369 426 326 461 343
1
Aritmètica David Buchaca - Prats Pràctica 6 Tardor 2010
mP QX = F unction[x, P owerM od[x, e, P Q]]/@mP Q −→ {4 922 073 027 081 664 063,
601 032 330 774 944 602,
1 306 048 600 200 164 626}
or
mP QX = P owerM od[mP Q, e, P Q] −→ {4 922 073 027 081 664 063,
601 032 330 774 944 602,
1 306 048 600 200 164 626}
mX95 = IntegerDigits[mP QX, 95] −→ {{7, 76, 87, 70, 82, 71, 44, 29, 23, 28},
{90, 56, 58, 79, 87, 62, 78, 9, 47},
{2, 6, 82, 24, 70, 63, 72, 53, 36, 6}}
2
Aritmètica David Buchaca - Prats Pràctica 6 Tardor 2010
ExtendedGCD[5, EulerP hi[P Q]] −→ {1, {−2 258 644 034 160 993 523, 1}}
d = %[[2]][[1]] −→ −2 258 644 034 160 993 523
mXT −→ {”0 lwf rgL = 7 < ”, ”zXZown )O”, ”&r8f hU D&”}
mXA = T oCharacterCode[mXT ] −→ {{39, 108, 119, 102, 114, 103, 76, 61, 55, 60},
{122, 88, 90, 111, 119, 94, 110, 41, 79},
{34, 38, 114, 56, 102, 95, 104, 85, 68, 38}}
mX95 = mXA − 32 −→ {{7, 76, 87, 70, 82, 71, 44, 29, 23, 28},
{90, 56, 58, 79, 87, 62, 78, 9, 47},
{2, 6, 82, 24, 70, 63, 72, 53, 36, 6}}
mXP Q = T able[F old[#1 ∗ 95 + #2&, −→ {4 922 073 027 081 664 063,
0, mX95[[k]]], {k, 1, Length[mX95]}] 601 032 330 774 944 602,
1 306 048 600 200 164 626}
mXP QY = F unction[x, P owerM od[x, d, P Q]] −→ {72 191 322 528 455 203,
/@mXP Q 6 844 883 447 154 901 843,
9 041 503 343 959 039 113}
3
Aritmètica David Buchaca - Prats Pràctica 6 Tardor 2010
P = P rime[6 570 730 109 871] −→ 209 896 172 349 301
Q = P rime[4 098 790 438 721] −→ 128 932 511 751 271
P owerM od[e, −1, EulerP hi[P ∗ Q]] −→ 20 366 400 884 370 586 811 253 365 099
(P Q, e) −→ (27 062 440 707 973 054 321 842 711 571, 1 632 899)
(P, Q, e) −→ (209 896 172 349 301, 128 932 511 751 27, 1 632 899)
Observem que M athematica necessita un temps molt llarg per calcular els primers
P i Q . El calcul de F actorInteger[P Q] encanvi es immediat.