2006/07 – Fase scolastica – 06

Cosa stampa il seguente programma?

Program cosa(Input, Output);

Function calcola(n: Integer): Integer;
Begin
   If n = 1 Then
      calcola:=1
   Else If n = 2 Then
      calcola:= 3
   Else If n = 3 Then
      calcola:=n+calcola(n-1)
   Else
      calcola:=n+calcola(n-1)+calcola(n-2)
End;

Begin
   Writeln(calcola(6));
End.

Risposte:

  1. 41
  2. 45
  3. 49
  4. nessuna delle precedenti.