

Funzioni ricorsive
Presentation
•
Computers
•
10th - 11th Grade
•
Hard
Giovanni Pedroncelli
Used 1+ times
FREE Resource
5 Slides • 0 Questions
1
Funzioni ricorsive
By Giovanni Pedroncelli
2
Funzioni ricorsive
Definizione
Una funzione ricorsiva è una funzione che contiene una chiamata a se stessa.
void fattoriale(int n){
.............................
fattoriale(n-1);
}
3
Funzioni ricorsive
Schema
Per evitare che la funzione chiami infinitamente se stessa è necessario fornire un modo per uscire dalla funzione terminandola
Due elementi distinti:
Condizione di terminazione della funzione (elemento NON ricorsivo)
Passo ricorsivo (di avvicinamento alla condizione di terminazione)
4
Funzioni ricorsive
Esempio
int fattoriale (int n){ //INTESTAZIONE FUNZIONE
if(n==1){ // CONDIZIONE DI TERMINAZIONE
return 1; // USCITA DALLA FUNZIONE
}
return fattoriale(n-1) * n; // CHIAMATA A SE STESSA E
// CONTEMPORANEAMENTE ANCHE PASSO DI AVVICINAMENTO
}
5
ISTRUZIONI | n | CHIAMATA |
|---|---|---|
Chiamata iniziale | 3 | fattoriale(3) |
Condizione FALSA (3==1) | | |
prima chiamata ricorsiva | | fattoriale(2) * 3 |
Condizione FALSA (2==1) | 2 | |
seconda chiamata ricorsiva | | fattoriale(1) * 2 |
CONDIZIONE VERA (1==1) | 1 | |
USCITA DALLA FUNZIONE | | return 1 |
Funzioni ricorsive
By Giovanni Pedroncelli
Show answer
Auto Play
Slide 1 / 5
SLIDE
Similar Resources on Wayground
11 questions
What you know?
Presentation
•
KG
8 questions
Presentazione testo narrativa e diario
Presentation
•
9th Grade
10 questions
Derivate 5N
Presentation
•
12th Grade
14 questions
Analisi del testo - recupero
Presentation
•
9th Grade
16 questions
Parità di genere e Costituzione italiana
Presentation
•
11th - 12th Grade
7 questions
L'APPARATO RESPIRATORIO
Presentation
•
7th Grade
4 questions
Le forze endogene
Presentation
•
11th Grade
7 questions
Variabili locali/globali
Presentation
•
10th Grade
Popular Resources on Wayground
6 questions
Secondary Safety Quiz
Presentation
•
9th - 12th Grade
10 questions
Afterschool Activities & Sports
Quiz
•
6th - 8th Grade
19 questions
ROAR Week 2026
Quiz
•
9th - 12th Grade
20 questions
Lab Safety Quiz
Quiz
•
6th Grade
15 questions
Cool Tool:Chromebook
Quiz
•
6th - 8th Grade
22 questions
would you rather
Quiz
•
3rd - 11th Grade
21 questions
Continents and Oceans
Quiz
•
6th Grade
20 questions
Parts of Speech
Quiz
•
5th Grade
Discover more resources for Computers
20 questions
Early Computing
Quiz
•
7th - 12th Grade
10 questions
Exploring the Parts of a Computer
Interactive video
•
6th - 10th Grade
10 questions
Navigating Digital Citizenship and Online Safety
Interactive video
•
6th - 10th Grade
20 questions
Binary Numbers
Quiz
•
11th Grade
10 questions
Mastering Proper Keyboarding Techniques
Interactive video
•
6th - 10th Grade