SlideShare a Scribd company logo
1 of 2
Please use only ONE recursive?thank you?
Please use c language? thank you?
1. (10 minutes) Write a program called fib.c that calculates the nth fibanocci number. The
equation for the Fibonacci numbers is defined as follows: Fib(0)-0 Fib(1)=1 Fib(N)= Fib(N-1)+
Fib(N-2) 2. Name your executable fib.out 3. Your program should accept N as a command line
argument 4. You MUST solve this program RECURSIVELY 5. Unlike the example in class, you
may only have ONE RECURSIVE CALL in your function 1. Hint pointers help make this
possible. 6. Here are the first 100 numbers in the Fibonacci sequence 7. 7. Examples 1../fib.out 0
2../fib.out 1 3../fib.out 10 The 0th fibanocci number is 0. The 1th fibanocci number is 1. The 10th
fibanocci number is 55.
Solution
//All libraries needed for this program. #include #include #include #include //Function
declarations. void fib(int fibNum1, int fibNum2, int count,int num); //This function takes in the
input and recursively calls itself until it hits the //base cases, where it takes in the input and
returns the nth fibonacci number. void fib(int fibNum1, int fibNum2, int count,int num) { //Base
case where it stops when it is either one or 0 and prints out the //result. if (count <= 1) { // Base
case: ran for user specified // number of steps, do nothing. //This is when the user inputs a 1, it
will print out. if(num == 2 && fibNum1 == 0 && count == 0){ printf("The 1th fibanocci
number is 1."); } //This is when the user inputs a 0, it will print out. else if(num == 2 &&
fibNum1 == 0){ printf("The 0th fibanocci number is 0."); } //Else, this is the classic base case,
where the program will print out the //nth Fibonacci number once it is reduced down to 1. else{
printf("The %dth fibanocci number is %d. ",num, fibNum1 + fibNum2); } } else { // Recursive
case: compute next value num++; fib(fibNum2, fibNum1 + fibNum2, count - 1,num); } return; }
//Main function that will run int main(int argc,char**argv) { //Variable declarations. int runFor =
0; runFor = atoi(argv[1]); // User specified number of values computed int num = 2; //Function
call to the function fib. fib(0, 1, runFor-1,num); return 0; }
Please use only ONE recursive-thank you- Please use c language- thank.docx

More Related Content

Similar to Please use only ONE recursive-thank you- Please use c language- thank.docx

Exploring Tailrec Through Time Until Kotlin.pptx
Exploring Tailrec Through Time Until Kotlin.pptxExploring Tailrec Through Time Until Kotlin.pptx
Exploring Tailrec Through Time Until Kotlin.pptxJoão Esperancinha
 
I need help coming up with a MIPS program for this.1.3. Overvi.pdf
I need help coming up with a MIPS program for this.1.3. Overvi.pdfI need help coming up with a MIPS program for this.1.3. Overvi.pdf
I need help coming up with a MIPS program for this.1.3. Overvi.pdfpratyushraj61
 
CMIS 102 Hands-On LabWeek 6OverviewThis hands-on lab .docx
CMIS 102 Hands-On LabWeek 6OverviewThis hands-on lab .docxCMIS 102 Hands-On LabWeek 6OverviewThis hands-on lab .docx
CMIS 102 Hands-On LabWeek 6OverviewThis hands-on lab .docxclarebernice
 
Effective Algorithm for n Fibonacci Number By: Professor Lili Saghafi
Effective Algorithm for n Fibonacci Number By: Professor Lili SaghafiEffective Algorithm for n Fibonacci Number By: Professor Lili Saghafi
Effective Algorithm for n Fibonacci Number By: Professor Lili SaghafiProfessor Lili Saghafi
 
Bottom of FormCreate your own FunctionFunctionsFor eac.docx
Bottom of FormCreate your own FunctionFunctionsFor eac.docxBottom of FormCreate your own FunctionFunctionsFor eac.docx
Bottom of FormCreate your own FunctionFunctionsFor eac.docxAASTHA76
 
OP 3014 Assignment 02 Please read about the Fibonacci numbers at http:...
OP 3014  Assignment 02  Please read about the Fibonacci numbers at      http:...OP 3014  Assignment 02  Please read about the Fibonacci numbers at      http:...
OP 3014 Assignment 02 Please read about the Fibonacci numbers at http:...hwbloom39
 
Modularization & Catch Statement
Modularization & Catch StatementModularization & Catch Statement
Modularization & Catch Statementsapdocs. info
 
컴퓨터 프로그램의 구조와 해석 1.2
컴퓨터  프로그램의 구조와 해석 1.2컴퓨터  프로그램의 구조와 해석 1.2
컴퓨터 프로그램의 구조와 해석 1.2HyeonSeok Choi
 
Python recursion
Python recursionPython recursion
Python recursionToniyaP1
 
I need help getting my mips program completed this are the full inst.pdf
I need help getting my mips program completed this are the full inst.pdfI need help getting my mips program completed this are the full inst.pdf
I need help getting my mips program completed this are the full inst.pdfallurafashions98
 
01 Notes Introduction Analysis of Algorithms Notes
01 Notes Introduction Analysis of Algorithms Notes01 Notes Introduction Analysis of Algorithms Notes
01 Notes Introduction Analysis of Algorithms NotesAndres Mendez-Vazquez
 
Catastrophic Cancellation
Catastrophic CancellationCatastrophic Cancellation
Catastrophic CancellationC4Media
 
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docxJLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docxvrickens
 
Concept_of_NAN_IND_INF_DEN_Using_C++
Concept_of_NAN_IND_INF_DEN_Using_C++Concept_of_NAN_IND_INF_DEN_Using_C++
Concept_of_NAN_IND_INF_DEN_Using_C++Mohammed Nisamudheen
 

Similar to Please use only ONE recursive-thank you- Please use c language- thank.docx (20)

Exploring Tailrec Through Time Until Kotlin.pptx
Exploring Tailrec Through Time Until Kotlin.pptxExploring Tailrec Through Time Until Kotlin.pptx
Exploring Tailrec Through Time Until Kotlin.pptx
 
Recursion.pdf
Recursion.pdfRecursion.pdf
Recursion.pdf
 
14. Recursion.pdf
14. Recursion.pdf14. Recursion.pdf
14. Recursion.pdf
 
I need help coming up with a MIPS program for this.1.3. Overvi.pdf
I need help coming up with a MIPS program for this.1.3. Overvi.pdfI need help coming up with a MIPS program for this.1.3. Overvi.pdf
I need help coming up with a MIPS program for this.1.3. Overvi.pdf
 
CMIS 102 Hands-On LabWeek 6OverviewThis hands-on lab .docx
CMIS 102 Hands-On LabWeek 6OverviewThis hands-on lab .docxCMIS 102 Hands-On LabWeek 6OverviewThis hands-on lab .docx
CMIS 102 Hands-On LabWeek 6OverviewThis hands-on lab .docx
 
Effective Algorithm for n Fibonacci Number By: Professor Lili Saghafi
Effective Algorithm for n Fibonacci Number By: Professor Lili SaghafiEffective Algorithm for n Fibonacci Number By: Professor Lili Saghafi
Effective Algorithm for n Fibonacci Number By: Professor Lili Saghafi
 
Bottom of FormCreate your own FunctionFunctionsFor eac.docx
Bottom of FormCreate your own FunctionFunctionsFor eac.docxBottom of FormCreate your own FunctionFunctionsFor eac.docx
Bottom of FormCreate your own FunctionFunctionsFor eac.docx
 
Fibonacci using matlab
Fibonacci using matlabFibonacci using matlab
Fibonacci using matlab
 
OP 3014 Assignment 02 Please read about the Fibonacci numbers at http:...
OP 3014  Assignment 02  Please read about the Fibonacci numbers at      http:...OP 3014  Assignment 02  Please read about the Fibonacci numbers at      http:...
OP 3014 Assignment 02 Please read about the Fibonacci numbers at http:...
 
Modularization & Catch Statement
Modularization & Catch StatementModularization & Catch Statement
Modularization & Catch Statement
 
컴퓨터 프로그램의 구조와 해석 1.2
컴퓨터  프로그램의 구조와 해석 1.2컴퓨터  프로그램의 구조와 해석 1.2
컴퓨터 프로그램의 구조와 해석 1.2
 
Defer, Panic, Recover
Defer, Panic, RecoverDefer, Panic, Recover
Defer, Panic, Recover
 
Python recursion
Python recursionPython recursion
Python recursion
 
I need help getting my mips program completed this are the full inst.pdf
I need help getting my mips program completed this are the full inst.pdfI need help getting my mips program completed this are the full inst.pdf
I need help getting my mips program completed this are the full inst.pdf
 
01 Notes Introduction Analysis of Algorithms Notes
01 Notes Introduction Analysis of Algorithms Notes01 Notes Introduction Analysis of Algorithms Notes
01 Notes Introduction Analysis of Algorithms Notes
 
Catastrophic Cancellation
Catastrophic CancellationCatastrophic Cancellation
Catastrophic Cancellation
 
Demo1 use numpy
Demo1 use numpyDemo1 use numpy
Demo1 use numpy
 
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docxJLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
JLK Chapter 5 – Methods and ModularityDRAFT January 2015 Edition.docx
 
Python PCEP Loops
Python PCEP LoopsPython PCEP Loops
Python PCEP Loops
 
Concept_of_NAN_IND_INF_DEN_Using_C++
Concept_of_NAN_IND_INF_DEN_Using_C++Concept_of_NAN_IND_INF_DEN_Using_C++
Concept_of_NAN_IND_INF_DEN_Using_C++
 

More from rtodd884

Poly-meta-morphic malware looks different each time it is stored on di.docx
Poly-meta-morphic malware looks different each time it is stored on di.docxPoly-meta-morphic malware looks different each time it is stored on di.docx
Poly-meta-morphic malware looks different each time it is stored on di.docxrtodd884
 
Please write a formal summary of the case before proceeding to answer.docx
Please write a formal summary of the case before proceeding to answer.docxPlease write a formal summary of the case before proceeding to answer.docx
Please write a formal summary of the case before proceeding to answer.docxrtodd884
 
Please respond in detail with an example- Thank you! Financial interme.docx
Please respond in detail with an example- Thank you! Financial interme.docxPlease respond in detail with an example- Thank you! Financial interme.docx
Please respond in detail with an example- Thank you! Financial interme.docxrtodd884
 
Problem 1- Text Editor using files and strings using C++ In this proje.docx
Problem 1- Text Editor using files and strings using C++ In this proje.docxProblem 1- Text Editor using files and strings using C++ In this proje.docx
Problem 1- Text Editor using files and strings using C++ In this proje.docxrtodd884
 
Presented below is the balance sheet of Sargent Corporation for the cu.docx
Presented below is the balance sheet of Sargent Corporation for the cu.docxPresented below is the balance sheet of Sargent Corporation for the cu.docx
Presented below is the balance sheet of Sargent Corporation for the cu.docxrtodd884
 
Presented below is information related to Dino Radja Company- Date End.docx
Presented below is information related to Dino Radja Company- Date End.docxPresented below is information related to Dino Radja Company- Date End.docx
Presented below is information related to Dino Radja Company- Date End.docxrtodd884
 
Prepare the journal entry to record salaries payable for the month of.docx
Prepare the journal entry to record salaries payable for the month of.docxPrepare the journal entry to record salaries payable for the month of.docx
Prepare the journal entry to record salaries payable for the month of.docxrtodd884
 
Prepare a short --talking points-- paper in which you identify and dis.docx
Prepare a short --talking points-- paper in which you identify and dis.docxPrepare a short --talking points-- paper in which you identify and dis.docx
Prepare a short --talking points-- paper in which you identify and dis.docxrtodd884
 

More from rtodd884 (8)

Poly-meta-morphic malware looks different each time it is stored on di.docx
Poly-meta-morphic malware looks different each time it is stored on di.docxPoly-meta-morphic malware looks different each time it is stored on di.docx
Poly-meta-morphic malware looks different each time it is stored on di.docx
 
Please write a formal summary of the case before proceeding to answer.docx
Please write a formal summary of the case before proceeding to answer.docxPlease write a formal summary of the case before proceeding to answer.docx
Please write a formal summary of the case before proceeding to answer.docx
 
Please respond in detail with an example- Thank you! Financial interme.docx
Please respond in detail with an example- Thank you! Financial interme.docxPlease respond in detail with an example- Thank you! Financial interme.docx
Please respond in detail with an example- Thank you! Financial interme.docx
 
Problem 1- Text Editor using files and strings using C++ In this proje.docx
Problem 1- Text Editor using files and strings using C++ In this proje.docxProblem 1- Text Editor using files and strings using C++ In this proje.docx
Problem 1- Text Editor using files and strings using C++ In this proje.docx
 
Presented below is the balance sheet of Sargent Corporation for the cu.docx
Presented below is the balance sheet of Sargent Corporation for the cu.docxPresented below is the balance sheet of Sargent Corporation for the cu.docx
Presented below is the balance sheet of Sargent Corporation for the cu.docx
 
Presented below is information related to Dino Radja Company- Date End.docx
Presented below is information related to Dino Radja Company- Date End.docxPresented below is information related to Dino Radja Company- Date End.docx
Presented below is information related to Dino Radja Company- Date End.docx
 
Prepare the journal entry to record salaries payable for the month of.docx
Prepare the journal entry to record salaries payable for the month of.docxPrepare the journal entry to record salaries payable for the month of.docx
Prepare the journal entry to record salaries payable for the month of.docx
 
Prepare a short --talking points-- paper in which you identify and dis.docx
Prepare a short --talking points-- paper in which you identify and dis.docxPrepare a short --talking points-- paper in which you identify and dis.docx
Prepare a short --talking points-- paper in which you identify and dis.docx
 

Recently uploaded

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 

Recently uploaded (20)

Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 

Please use only ONE recursive-thank you- Please use c language- thank.docx

  • 1. Please use only ONE recursive?thank you? Please use c language? thank you? 1. (10 minutes) Write a program called fib.c that calculates the nth fibanocci number. The equation for the Fibonacci numbers is defined as follows: Fib(0)-0 Fib(1)=1 Fib(N)= Fib(N-1)+ Fib(N-2) 2. Name your executable fib.out 3. Your program should accept N as a command line argument 4. You MUST solve this program RECURSIVELY 5. Unlike the example in class, you may only have ONE RECURSIVE CALL in your function 1. Hint pointers help make this possible. 6. Here are the first 100 numbers in the Fibonacci sequence 7. 7. Examples 1../fib.out 0 2../fib.out 1 3../fib.out 10 The 0th fibanocci number is 0. The 1th fibanocci number is 1. The 10th fibanocci number is 55. Solution //All libraries needed for this program. #include #include #include #include //Function declarations. void fib(int fibNum1, int fibNum2, int count,int num); //This function takes in the input and recursively calls itself until it hits the //base cases, where it takes in the input and returns the nth fibonacci number. void fib(int fibNum1, int fibNum2, int count,int num) { //Base case where it stops when it is either one or 0 and prints out the //result. if (count <= 1) { // Base case: ran for user specified // number of steps, do nothing. //This is when the user inputs a 1, it will print out. if(num == 2 && fibNum1 == 0 && count == 0){ printf("The 1th fibanocci number is 1."); } //This is when the user inputs a 0, it will print out. else if(num == 2 && fibNum1 == 0){ printf("The 0th fibanocci number is 0."); } //Else, this is the classic base case, where the program will print out the //nth Fibonacci number once it is reduced down to 1. else{ printf("The %dth fibanocci number is %d. ",num, fibNum1 + fibNum2); } } else { // Recursive case: compute next value num++; fib(fibNum2, fibNum1 + fibNum2, count - 1,num); } return; } //Main function that will run int main(int argc,char**argv) { //Variable declarations. int runFor = 0; runFor = atoi(argv[1]); // User specified number of values computed int num = 2; //Function call to the function fib. fib(0, 1, runFor-1,num); return 0; }