fromcardiacimport*# Programme CARDIAC pour calculer la somme des nombres de 1 à N (N en entrée)
pgm={10:[000],# INP : Lire N en entrée et le stocker en 00
11:[601],# STO : Stocker N dans la mémoire 01 (compteur)
12:[600],# STO : Initialiser la somme à 0 (adresse 00)
13:[101],# CLA : Charger le compteur
14:[700],# SUB : Soustraire la somme actuelle
15:[600],# STO : Stocker la nouvelle somme
16:[201],# ADD : Ajouter le compteur à la somme
17:[601],# STO : Mettre à jour la somme
18:[701],# SUB : Soustraire 1 du compteur
19:[601],# STO : Stocker le compteur mis à jour
20:[301],# TAC : Si le compteur < 0, aller à 22
21:[818],# JMP : Boucler pour ajouter le prochain nombre
22:[500],# OUT : Afficher la somme totale
23:[900]# HRS : Arrêter le programme
}reg={}tape=[10]# L'utilisateur entre ici la valeur de N
cpu=cardiac(pgm,reg,tape)output=cpu.run()
During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:
Ensure the proper functioning of the site (essential cookies); and
Track your browsing to send you personalized communications if you have created a professional account on the site and can be contacted (audience measurement cookies).
With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.