SlideShare ist ein Scribd-Unternehmen logo
1 von 1
Downloaden Sie, um offline zu lesen
Define a recursive algorithm to find the nth term of the sequence defined by a0 = 1 , a1 = 2, and
an = an-1 x an-2 for n = 2,3,4...
Solution
I suppose we could use some pseudocode: int sequence (int n) { if (n == 0) return 1
if (n == 1) return 2; return sequence (n-1) * sequence (n-2); } Note that this uses "tail"
recursion in the last line, so it's easily convertible to a loop for your other question.

Weitere ähnliche Inhalte

Mehr von alshaikhkhanzariarts

Define asymmetric information. Distinguish between hidden characteri.pdf
Define asymmetric information. Distinguish between hidden characteri.pdfDefine asymmetric information. Distinguish between hidden characteri.pdf
Define asymmetric information. Distinguish between hidden characteri.pdfalshaikhkhanzariarts
 
define the following types of asymptotic behavior of a function of t.pdf
define the following types of asymptotic behavior of a function of t.pdfdefine the following types of asymptotic behavior of a function of t.pdf
define the following types of asymptotic behavior of a function of t.pdfalshaikhkhanzariarts
 
Define cyberbullying and use two workable ethical theories to analyz.pdf
Define cyberbullying and use two workable ethical theories to analyz.pdfDefine cyberbullying and use two workable ethical theories to analyz.pdf
Define cyberbullying and use two workable ethical theories to analyz.pdfalshaikhkhanzariarts
 
define and explain the difference between Consumer Perception, Consu.pdf
define and explain the difference between Consumer Perception, Consu.pdfdefine and explain the difference between Consumer Perception, Consu.pdf
define and explain the difference between Consumer Perception, Consu.pdfalshaikhkhanzariarts
 
Define and explain significant noncash investing and financing activ.pdf
Define and explain significant noncash investing and financing activ.pdfDefine and explain significant noncash investing and financing activ.pdf
Define and explain significant noncash investing and financing activ.pdfalshaikhkhanzariarts
 
Describe briefly FIVE major developments over the past twenty years .pdf
Describe briefly FIVE major developments over the past twenty years .pdfDescribe briefly FIVE major developments over the past twenty years .pdf
Describe briefly FIVE major developments over the past twenty years .pdfalshaikhkhanzariarts
 
Describe briefly, the primary activities of a value chain.Soluti.pdf
Describe briefly, the primary activities of a value chain.Soluti.pdfDescribe briefly, the primary activities of a value chain.Soluti.pdf
Describe briefly, the primary activities of a value chain.Soluti.pdfalshaikhkhanzariarts
 
Describe by legal name all parties to a contract assignment. May all.pdf
Describe by legal name all parties to a contract assignment. May all.pdfDescribe by legal name all parties to a contract assignment. May all.pdf
Describe by legal name all parties to a contract assignment. May all.pdfalshaikhkhanzariarts
 
Describe at least 4 reasons a company would use a performance evalua.pdf
Describe at least 4 reasons a company would use a performance evalua.pdfDescribe at least 4 reasons a company would use a performance evalua.pdf
Describe at least 4 reasons a company would use a performance evalua.pdfalshaikhkhanzariarts
 
Describe and explain satellite remote sensing mission for monitoring.pdf
Describe and explain satellite remote sensing mission for monitoring.pdfDescribe and explain satellite remote sensing mission for monitoring.pdf
Describe and explain satellite remote sensing mission for monitoring.pdfalshaikhkhanzariarts
 
Describe an algorithm that takes as input a list of n integers in no.pdf
Describe an algorithm that takes as input a list of n integers in no.pdfDescribe an algorithm that takes as input a list of n integers in no.pdf
Describe an algorithm that takes as input a list of n integers in no.pdfalshaikhkhanzariarts
 
Describe an initial public offering for a global firm (Red Bull). 15.pdf
Describe an initial public offering for a global firm (Red Bull). 15.pdfDescribe an initial public offering for a global firm (Red Bull). 15.pdf
Describe an initial public offering for a global firm (Red Bull). 15.pdfalshaikhkhanzariarts
 
Describe activities that the Engineer can perform throughout the pro.pdf
Describe activities that the Engineer can perform throughout the pro.pdfDescribe activities that the Engineer can perform throughout the pro.pdf
Describe activities that the Engineer can perform throughout the pro.pdfalshaikhkhanzariarts
 
Describe a situation within a Supply Chain function that might easil.pdf
Describe a situation within a Supply Chain function that might easil.pdfDescribe a situation within a Supply Chain function that might easil.pdf
Describe a situation within a Supply Chain function that might easil.pdfalshaikhkhanzariarts
 
Describe a typical monitoring and control process in project managem.pdf
Describe a typical monitoring and control process in project managem.pdfDescribe a typical monitoring and control process in project managem.pdf
Describe a typical monitoring and control process in project managem.pdfalshaikhkhanzariarts
 
Describe a situation with two variables and an outlying score that w.pdf
Describe a situation with two variables and an outlying score that w.pdfDescribe a situation with two variables and an outlying score that w.pdf
Describe a situation with two variables and an outlying score that w.pdfalshaikhkhanzariarts
 
Describe a nonverbal communication technique that you will use to pe.pdf
Describe a nonverbal communication technique that you will use to pe.pdfDescribe a nonverbal communication technique that you will use to pe.pdf
Describe a nonverbal communication technique that you will use to pe.pdfalshaikhkhanzariarts
 
Describe 5 scenarios where you might need to use the Bernoulli’s Equ.pdf
Describe 5 scenarios where you might need to use the Bernoulli’s Equ.pdfDescribe 5 scenarios where you might need to use the Bernoulli’s Equ.pdf
Describe 5 scenarios where you might need to use the Bernoulli’s Equ.pdfalshaikhkhanzariarts
 
Deriving the least squares estimators, i need help please.So.pdf
Deriving the least squares estimators, i need help please.So.pdfDeriving the least squares estimators, i need help please.So.pdf
Deriving the least squares estimators, i need help please.So.pdfalshaikhkhanzariarts
 
Describe (in words) the difference between FickSolutionRecover.pdf
Describe (in words) the difference between FickSolutionRecover.pdfDescribe (in words) the difference between FickSolutionRecover.pdf
Describe (in words) the difference between FickSolutionRecover.pdfalshaikhkhanzariarts
 

Mehr von alshaikhkhanzariarts (20)

Define asymmetric information. Distinguish between hidden characteri.pdf
Define asymmetric information. Distinguish between hidden characteri.pdfDefine asymmetric information. Distinguish between hidden characteri.pdf
Define asymmetric information. Distinguish between hidden characteri.pdf
 
define the following types of asymptotic behavior of a function of t.pdf
define the following types of asymptotic behavior of a function of t.pdfdefine the following types of asymptotic behavior of a function of t.pdf
define the following types of asymptotic behavior of a function of t.pdf
 
Define cyberbullying and use two workable ethical theories to analyz.pdf
Define cyberbullying and use two workable ethical theories to analyz.pdfDefine cyberbullying and use two workable ethical theories to analyz.pdf
Define cyberbullying and use two workable ethical theories to analyz.pdf
 
define and explain the difference between Consumer Perception, Consu.pdf
define and explain the difference between Consumer Perception, Consu.pdfdefine and explain the difference between Consumer Perception, Consu.pdf
define and explain the difference between Consumer Perception, Consu.pdf
 
Define and explain significant noncash investing and financing activ.pdf
Define and explain significant noncash investing and financing activ.pdfDefine and explain significant noncash investing and financing activ.pdf
Define and explain significant noncash investing and financing activ.pdf
 
Describe briefly FIVE major developments over the past twenty years .pdf
Describe briefly FIVE major developments over the past twenty years .pdfDescribe briefly FIVE major developments over the past twenty years .pdf
Describe briefly FIVE major developments over the past twenty years .pdf
 
Describe briefly, the primary activities of a value chain.Soluti.pdf
Describe briefly, the primary activities of a value chain.Soluti.pdfDescribe briefly, the primary activities of a value chain.Soluti.pdf
Describe briefly, the primary activities of a value chain.Soluti.pdf
 
Describe by legal name all parties to a contract assignment. May all.pdf
Describe by legal name all parties to a contract assignment. May all.pdfDescribe by legal name all parties to a contract assignment. May all.pdf
Describe by legal name all parties to a contract assignment. May all.pdf
 
Describe at least 4 reasons a company would use a performance evalua.pdf
Describe at least 4 reasons a company would use a performance evalua.pdfDescribe at least 4 reasons a company would use a performance evalua.pdf
Describe at least 4 reasons a company would use a performance evalua.pdf
 
Describe and explain satellite remote sensing mission for monitoring.pdf
Describe and explain satellite remote sensing mission for monitoring.pdfDescribe and explain satellite remote sensing mission for monitoring.pdf
Describe and explain satellite remote sensing mission for monitoring.pdf
 
Describe an algorithm that takes as input a list of n integers in no.pdf
Describe an algorithm that takes as input a list of n integers in no.pdfDescribe an algorithm that takes as input a list of n integers in no.pdf
Describe an algorithm that takes as input a list of n integers in no.pdf
 
Describe an initial public offering for a global firm (Red Bull). 15.pdf
Describe an initial public offering for a global firm (Red Bull). 15.pdfDescribe an initial public offering for a global firm (Red Bull). 15.pdf
Describe an initial public offering for a global firm (Red Bull). 15.pdf
 
Describe activities that the Engineer can perform throughout the pro.pdf
Describe activities that the Engineer can perform throughout the pro.pdfDescribe activities that the Engineer can perform throughout the pro.pdf
Describe activities that the Engineer can perform throughout the pro.pdf
 
Describe a situation within a Supply Chain function that might easil.pdf
Describe a situation within a Supply Chain function that might easil.pdfDescribe a situation within a Supply Chain function that might easil.pdf
Describe a situation within a Supply Chain function that might easil.pdf
 
Describe a typical monitoring and control process in project managem.pdf
Describe a typical monitoring and control process in project managem.pdfDescribe a typical monitoring and control process in project managem.pdf
Describe a typical monitoring and control process in project managem.pdf
 
Describe a situation with two variables and an outlying score that w.pdf
Describe a situation with two variables and an outlying score that w.pdfDescribe a situation with two variables and an outlying score that w.pdf
Describe a situation with two variables and an outlying score that w.pdf
 
Describe a nonverbal communication technique that you will use to pe.pdf
Describe a nonverbal communication technique that you will use to pe.pdfDescribe a nonverbal communication technique that you will use to pe.pdf
Describe a nonverbal communication technique that you will use to pe.pdf
 
Describe 5 scenarios where you might need to use the Bernoulli’s Equ.pdf
Describe 5 scenarios where you might need to use the Bernoulli’s Equ.pdfDescribe 5 scenarios where you might need to use the Bernoulli’s Equ.pdf
Describe 5 scenarios where you might need to use the Bernoulli’s Equ.pdf
 
Deriving the least squares estimators, i need help please.So.pdf
Deriving the least squares estimators, i need help please.So.pdfDeriving the least squares estimators, i need help please.So.pdf
Deriving the least squares estimators, i need help please.So.pdf
 
Describe (in words) the difference between FickSolutionRecover.pdf
Describe (in words) the difference between FickSolutionRecover.pdfDescribe (in words) the difference between FickSolutionRecover.pdf
Describe (in words) the difference between FickSolutionRecover.pdf
 

Kürzlich hochgeladen

Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...JhezDiaz1
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)lakshayb543
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinojohnmickonozaleda
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...Postal Advocate Inc.
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)cama23
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfTechSoup
 

Kürzlich hochgeladen (20)

Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
ENGLISH 7_Q4_LESSON 2_ Employing a Variety of Strategies for Effective Interp...
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
Visit to a blind student's school🧑‍🦯🧑‍🦯(community medicine)
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptxFINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
FINALS_OF_LEFT_ON_C'N_EL_DORADO_2024.pptx
 
FILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipinoFILIPINO PSYCHology sikolohiyang pilipino
FILIPINO PSYCHology sikolohiyang pilipino
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
USPS® Forced Meter Migration - How to Know if Your Postage Meter Will Soon be...
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)Global Lehigh Strategic Initiatives (without descriptions)
Global Lehigh Strategic Initiatives (without descriptions)
 
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdfInclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
Inclusivity Essentials_ Creating Accessible Websites for Nonprofits .pdf
 

Define a recursive algorithm to find the nth term of the sequence de.pdf

  • 1. Define a recursive algorithm to find the nth term of the sequence defined by a0 = 1 , a1 = 2, and an = an-1 x an-2 for n = 2,3,4... Solution I suppose we could use some pseudocode: int sequence (int n) { if (n == 0) return 1 if (n == 1) return 2; return sequence (n-1) * sequence (n-2); } Note that this uses "tail" recursion in the last line, so it's easily convertible to a loop for your other question.