FONCTION CalculEAN(sEAN)
sChaine est une chaîne
iInd est un entier
iCheckSum est une entier = 0
sCtrl est une chaîne
SI Taille(sEAN)<>0 ALORS
//Inversion de la chaine EAN
POUR iInd=Taille(sEAN) A 1 PAS -1
sChaine+=sEAN[[iInd]]
FIN
//Cacul du caractère de contrôle
POUR iInd=1 A Taille(sChaine)
SI PartieDécimale(iInd/2)=0 ALORS
//Paire
iCheckSum+=Val(sChaine[[iInd]])
SINON
//Impaire
iCheckSum+=Val(sChaine[[iInd]])*3
FIN
FIN
sCtrl=Droite(NumériqueVersChaine(10-modulo(iCheckSum,10)),1)
SINON
Erreur("La taille du code EAN est nulle.")
FIN
RENVOYER sCtrl