NSI RECURSIVE

def pgcd_recursif(a, b):
     if b == 0: 
        return a
     else: ...
 
 
 Le code suivant est incomplet, il manque l'appel récursif :
Return pgcd_recursif(a, b)
Return pgcd_recursif(a // b, a % b)
Return pgcd_recursif(a % b, b)
Return pgcd_recursif(b, a % b)
Return a %b
def affiche(n):
      print(n)
      if n>=0:
          affiche(n-1)
Quel affichage obtient-on en exécutant affiche(3)
0 1 2 3
4
3
3 2 1 0 -1
647774747
def g(n):
     assert n>=0
     if n==0 :
        return 1789
     else :
        return g(n-2)
 
Qu'obtient-on en exécutant la commande g(3)?
AssertionError
1789
1
Tres different
RecursionError
def mystere(n):
     if n>0 :
        return mystere(n-2)
     else :
        return n==0
 

Que retourne la commande suivante ?

mystere(4)
True
TD
True
False
L'exécution génère une erreur.
def copy(n,s):
      if n==0:
         return s
      return copy(n-1, s+s)
 
Que retourne l'instruction copy(3,'A') ?
'AAA'
'AAAAAA'
'AAAAAAA'
'3A'
Je ne sais pas...
'AAAAAAAA'
{"name":"NSI RECURSIVE", "url":"https://www.quiz-maker.com/QPREVIEW","txt":"def pgcd_recursif(a, b):      if b == 0:          return a      else: ...      Le code suivant est incomplet, il manque l'appel récursif :, def affiche(n):       print(n)       if n>=0:           affiche(n-1) Quel affichage obtient-on en exécutant affiche(3), def g(n):      assert n>=0      if n==0 :         return 1789      else :         return g(n-2)   Qu'obtient-on en exécutant la commande g(3)?","img":"https://www.quiz-maker.com/3012/images/ogquiz.png"}
Make your own Survey
- it's free to start.