-- Opération sur les Grands Nombres GN
supportedOrientations(LANDSCAPE_ANY) ; displayMode(FULLSCREEN)
function setup()
A="45896328714523695" ; A2=ENG(A) ; B="45892631745" ; B2=ENG(B)
C=ADD(A,B) ; C2=ENG(C) ; D=MULT(A,B) ; D2=ENG(D)
E=FACT("25") ; E2=ENG(E) ; F=FIB("50") ; F2=ENG(F)
G=PUIS("99",9) ; G2=ENG(G)
end
function draw()
background(31, 29, 146, 255) ; strokeWidth(5) ; font("AmericanTypewriter")
fontSize(35) ; textMode(CORNER) ; fill(175, 116, 24, 255)
text("Opération sur les Grands Nombres :",30,700)
fill(226, 58, 23, 255)
text("A =",30,600) ; text("B =",30,550)
text(A2,100+800-textSize(A2),600) ; text(B2,100+800-textSize(B2),550)
fill(255, 238, 0, 255)
text("A+B =",30,500) ; text(C2,100+800-textSize(C2),500)
text("A*B =",30,450) ; text(D2,100+800-textSize(D2),450)
fill(55, 203, 20, 255)
text("25! =",30,350) ; text(E2,100+800-textSize(E2),350)
text("FIB(50) =",30,300) ; text(F2,100+800-textSize(F2),300)
fill(214, 16, 208, 255)
text("99^9 =",30,250) ; text(G2,100+800-textSize(G2),250)
end
function ADD(A_ADD,B_ADD)
A_ADD_SIZE=string.len(A_ADD) ; B_ADD_SIZE=string.len(B_ADD)
if A_ADD_SIZE<B_ADD_SIZE then TMP=A_ADD ; A_ADD=B_ADD ; B_ADD=TMP
TMP=A_ADD_SIZE ; A_ADD_SIZE=B_ADD_SIZE ; B_ADD_SIZE=TMP end
retenue=0 ; result = ""
for i=1, A_ADD_SIZE do if i<=B_ADD_SIZE then
vala=string.sub(A_ADD,A_ADD_SIZE-i+1,A_ADD_SIZE-i+1)
valb=string.sub(B_ADD,B_ADD_SIZE-i+1,B_ADD_SIZE-i+1) ; valc=vala+valb ; valc=valc+retenue
else vala=string.sub(A_ADD,A_ADD_SIZE-i+1,A_ADD_SIZE-i+1) ; valc=vala+retenue end
if valc>9 then retenue=1 ; valc=string.sub(valc,2,2) else retenue=0 end
result = valc .. result
end
if retenue~=0 then result = retenue .. result end
return result
end
function MOINS(A_MOINS,B_MOINS)
end
function MULT(A_MUL,B_MUL)
A_MUL_SIZE=string.len(A_MUL) ; B_MUL_SIZE=string.len(B_MUL) ; total="0"
for j=B_MUL_SIZE, 1, -1 do
valb=string.sub(B_MUL,j,j) ; valb2=tonumber(valb) ; retenue=0 ; result=""
for i=1, A_MUL_SIZE do vala=string.sub(A_MUL,A_MUL_SIZE-i+1,A_MUL_SIZE-i+1)
vala2=tonumber(vala) ; valc = valb2 * vala2 + retenue
if valc>9 then retenue=math.floor(valc/10) ; valc=valc-retenue*10 else retenue=0 end
result = valc .. result
end
if retenue~=0 then result = retenue .. result end
result = result .. string.rep("0",B_MUL_SIZE-j) ; total=ADD(total,result)
end
return result
end
function DIV(A_DIV,B_DIV)
end
function PUIS(A_PUISS,N_PUISS)
C="1"
for i=1, N_PUISS do
C=MULT(C,A_PUISS)
end
return C
end
function RACN(A_RACN,B_RACN)
end
function EXP(A_EXP,B_EXP)
end
function LOG(A_LOG,B_LOG)
end
function COMB(A_COMB,B_COMB)
end
function PERM(A_PERM,B_PERM)
end
function ALEA(A_ALEA,B_ALEA)
end
function ENG(str)
taille=string.len(str) ; str2="" ; n=0
for i=taille, 1, -1 do n = n + 1 ; str2 = string.sub(str,i,i) .. str2
if math.fmod(n,3)==0 and n~=taille then str2 = "." .. str2 end
end ; return str2
end
function IPART()
end
function FPART()
end
function FIB(N_FIB)
A="0" ; B="1"
for i=0, N_FIB do
if i<2 then
if i==0 then C="0" end
if i==1 then C="1" end
else
C=ADD(A,B)
A=B
B=C
end
end
return C
end
function FACT(A_FACT)
vala=tonumber(A_FACT) ; result="1"
for i=1, vala do result = MULT(result,""..i) end
return result
end