SlideShare a Scribd company logo
1 of 2
Insert the missing code in the following code fragment. This fragment is intended to recursively
compute xn, where x and n are both non-negative integers:
public int power(int x, int n)
{
if (n == 0)
{
____________________
} else
{
return x * power(x, n - 1);
} }
a) return 1;
b) return x;
c) return power(x, n - 1);
d) return x * power(x, n - 1);
Solution
And: a) return 1;
public int power(int x, int n){
// base case, zero power of any number is 1
if(n==0){
return 1;
}
else{
return x*pow(x, n-1);
}
}

More Related Content

More from rtodd972

In what way (or ways) is the current Knowledge Revolution a child of t.docx
In what way (or ways) is the current Knowledge Revolution a child of t.docxIn what way (or ways) is the current Knowledge Revolution a child of t.docx
In what way (or ways) is the current Knowledge Revolution a child of t.docxrtodd972
 
In the Lewis structures listed below- M and X represent various elemen.docx
In the Lewis structures listed below- M and X represent various elemen.docxIn the Lewis structures listed below- M and X represent various elemen.docx
In the Lewis structures listed below- M and X represent various elemen.docxrtodd972
 
In the independent data marts architecture- the independent data marts.docx
In the independent data marts architecture- the independent data marts.docxIn the independent data marts architecture- the independent data marts.docx
In the independent data marts architecture- the independent data marts.docxrtodd972
 
iron (III) chloride + sodium thiosulfate - write the half reactions an.docx
iron (III) chloride + sodium thiosulfate - write the half reactions an.docxiron (III) chloride + sodium thiosulfate - write the half reactions an.docx
iron (III) chloride + sodium thiosulfate - write the half reactions an.docxrtodd972
 
It has been said that the advantage that leading-edge retailers such a.docx
It has been said that the advantage that leading-edge retailers such a.docxIt has been said that the advantage that leading-edge retailers such a.docx
It has been said that the advantage that leading-edge retailers such a.docxrtodd972
 
ISP who has allowed them the use of 4 externally routable IP addresses.docx
ISP who has allowed them the use of 4 externally routable IP addresses.docxISP who has allowed them the use of 4 externally routable IP addresses.docx
ISP who has allowed them the use of 4 externally routable IP addresses.docxrtodd972
 
Is TOD a input or output-- Is this correct--- Inputs- start- stop- fl.docx
Is TOD a input or output--  Is this correct--- Inputs- start- stop- fl.docxIs TOD a input or output--  Is this correct--- Inputs- start- stop- fl.docx
Is TOD a input or output-- Is this correct--- Inputs- start- stop- fl.docxrtodd972
 
Is there a universal code for ethical business behavior- (Check the De.docx
Is there a universal code for ethical business behavior- (Check the De.docxIs there a universal code for ethical business behavior- (Check the De.docx
Is there a universal code for ethical business behavior- (Check the De.docxrtodd972
 
In the following search function for a linked list (using the Node and.docx
In the following search function for a linked list (using the Node and.docxIn the following search function for a linked list (using the Node and.docx
In the following search function for a linked list (using the Node and.docxrtodd972
 
Is it easier to perform a computer forensic investigation if the suspe.docx
Is it easier to perform a computer forensic investigation if the suspe.docxIs it easier to perform a computer forensic investigation if the suspe.docx
Is it easier to perform a computer forensic investigation if the suspe.docxrtodd972
 
Is a public park considered to be a public good- Why or why not-Soluti.docx
Is a public park considered to be a public good- Why or why not-Soluti.docxIs a public park considered to be a public good- Why or why not-Soluti.docx
Is a public park considered to be a public good- Why or why not-Soluti.docxrtodd972
 
Is a firm-'s 10-K an unbiased perspective on its strengths and weaknes.docx
Is a firm-'s 10-K an unbiased perspective on its strengths and weaknes.docxIs a firm-'s 10-K an unbiased perspective on its strengths and weaknes.docx
Is a firm-'s 10-K an unbiased perspective on its strengths and weaknes.docxrtodd972
 
Iron(II) ion reacts with water to a small extent by a hydrolysis react.docx
Iron(II) ion reacts with water to a small extent by a hydrolysis react.docxIron(II) ion reacts with water to a small extent by a hydrolysis react.docx
Iron(II) ion reacts with water to a small extent by a hydrolysis react.docxrtodd972
 
Investors require a 17- rate of return on Levine Company-'s stock (tha.docx
Investors require a 17- rate of return on Levine Company-'s stock (tha.docxInvestors require a 17- rate of return on Levine Company-'s stock (tha.docx
Investors require a 17- rate of return on Levine Company-'s stock (tha.docxrtodd972
 
ionic compounds crystallize in a cubic closest packed array of anions.docx
ionic compounds crystallize in a cubic closest packed array of anions.docxionic compounds crystallize in a cubic closest packed array of anions.docx
ionic compounds crystallize in a cubic closest packed array of anions.docxrtodd972
 
Invoke Netbeans and create a project Exercise 7- Enter the following.docx
Invoke Netbeans and create a project Exercise 7-  Enter the following.docxInvoke Netbeans and create a project Exercise 7-  Enter the following.docx
Invoke Netbeans and create a project Exercise 7- Enter the following.docxrtodd972
 
Investors and management use the statement of cash flows to evaluate a.docx
Investors and management use the statement of cash flows to evaluate a.docxInvestors and management use the statement of cash flows to evaluate a.docx
Investors and management use the statement of cash flows to evaluate a.docxrtodd972
 
In the short run- what distinguishes liquidity from profitability- 1-.docx
In the short run- what distinguishes liquidity from profitability- 1-.docxIn the short run- what distinguishes liquidity from profitability- 1-.docx
In the short run- what distinguishes liquidity from profitability- 1-.docxrtodd972
 

More from rtodd972 (18)

In what way (or ways) is the current Knowledge Revolution a child of t.docx
In what way (or ways) is the current Knowledge Revolution a child of t.docxIn what way (or ways) is the current Knowledge Revolution a child of t.docx
In what way (or ways) is the current Knowledge Revolution a child of t.docx
 
In the Lewis structures listed below- M and X represent various elemen.docx
In the Lewis structures listed below- M and X represent various elemen.docxIn the Lewis structures listed below- M and X represent various elemen.docx
In the Lewis structures listed below- M and X represent various elemen.docx
 
In the independent data marts architecture- the independent data marts.docx
In the independent data marts architecture- the independent data marts.docxIn the independent data marts architecture- the independent data marts.docx
In the independent data marts architecture- the independent data marts.docx
 
iron (III) chloride + sodium thiosulfate - write the half reactions an.docx
iron (III) chloride + sodium thiosulfate - write the half reactions an.docxiron (III) chloride + sodium thiosulfate - write the half reactions an.docx
iron (III) chloride + sodium thiosulfate - write the half reactions an.docx
 
It has been said that the advantage that leading-edge retailers such a.docx
It has been said that the advantage that leading-edge retailers such a.docxIt has been said that the advantage that leading-edge retailers such a.docx
It has been said that the advantage that leading-edge retailers such a.docx
 
ISP who has allowed them the use of 4 externally routable IP addresses.docx
ISP who has allowed them the use of 4 externally routable IP addresses.docxISP who has allowed them the use of 4 externally routable IP addresses.docx
ISP who has allowed them the use of 4 externally routable IP addresses.docx
 
Is TOD a input or output-- Is this correct--- Inputs- start- stop- fl.docx
Is TOD a input or output--  Is this correct--- Inputs- start- stop- fl.docxIs TOD a input or output--  Is this correct--- Inputs- start- stop- fl.docx
Is TOD a input or output-- Is this correct--- Inputs- start- stop- fl.docx
 
Is there a universal code for ethical business behavior- (Check the De.docx
Is there a universal code for ethical business behavior- (Check the De.docxIs there a universal code for ethical business behavior- (Check the De.docx
Is there a universal code for ethical business behavior- (Check the De.docx
 
In the following search function for a linked list (using the Node and.docx
In the following search function for a linked list (using the Node and.docxIn the following search function for a linked list (using the Node and.docx
In the following search function for a linked list (using the Node and.docx
 
Is it easier to perform a computer forensic investigation if the suspe.docx
Is it easier to perform a computer forensic investigation if the suspe.docxIs it easier to perform a computer forensic investigation if the suspe.docx
Is it easier to perform a computer forensic investigation if the suspe.docx
 
Is a public park considered to be a public good- Why or why not-Soluti.docx
Is a public park considered to be a public good- Why or why not-Soluti.docxIs a public park considered to be a public good- Why or why not-Soluti.docx
Is a public park considered to be a public good- Why or why not-Soluti.docx
 
Is a firm-'s 10-K an unbiased perspective on its strengths and weaknes.docx
Is a firm-'s 10-K an unbiased perspective on its strengths and weaknes.docxIs a firm-'s 10-K an unbiased perspective on its strengths and weaknes.docx
Is a firm-'s 10-K an unbiased perspective on its strengths and weaknes.docx
 
Iron(II) ion reacts with water to a small extent by a hydrolysis react.docx
Iron(II) ion reacts with water to a small extent by a hydrolysis react.docxIron(II) ion reacts with water to a small extent by a hydrolysis react.docx
Iron(II) ion reacts with water to a small extent by a hydrolysis react.docx
 
Investors require a 17- rate of return on Levine Company-'s stock (tha.docx
Investors require a 17- rate of return on Levine Company-'s stock (tha.docxInvestors require a 17- rate of return on Levine Company-'s stock (tha.docx
Investors require a 17- rate of return on Levine Company-'s stock (tha.docx
 
ionic compounds crystallize in a cubic closest packed array of anions.docx
ionic compounds crystallize in a cubic closest packed array of anions.docxionic compounds crystallize in a cubic closest packed array of anions.docx
ionic compounds crystallize in a cubic closest packed array of anions.docx
 
Invoke Netbeans and create a project Exercise 7- Enter the following.docx
Invoke Netbeans and create a project Exercise 7-  Enter the following.docxInvoke Netbeans and create a project Exercise 7-  Enter the following.docx
Invoke Netbeans and create a project Exercise 7- Enter the following.docx
 
Investors and management use the statement of cash flows to evaluate a.docx
Investors and management use the statement of cash flows to evaluate a.docxInvestors and management use the statement of cash flows to evaluate a.docx
Investors and management use the statement of cash flows to evaluate a.docx
 
In the short run- what distinguishes liquidity from profitability- 1-.docx
In the short run- what distinguishes liquidity from profitability- 1-.docxIn the short run- what distinguishes liquidity from profitability- 1-.docx
In the short run- what distinguishes liquidity from profitability- 1-.docx
 

Recently uploaded

Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxnelietumpap1
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
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
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptxmary850239
 

Recently uploaded (20)

Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptx
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
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
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
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
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
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
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx4.18.24 Movement Legacies, Reflection, and Review.pptx
4.18.24 Movement Legacies, Reflection, and Review.pptx
 

Insert the missing code in the following code fragment- This fragment.docx

  • 1. Insert the missing code in the following code fragment. This fragment is intended to recursively compute xn, where x and n are both non-negative integers: public int power(int x, int n) { if (n == 0) { ____________________ } else { return x * power(x, n - 1); } } a) return 1; b) return x; c) return power(x, n - 1); d) return x * power(x, n - 1); Solution And: a) return 1; public int power(int x, int n){
  • 2. // base case, zero power of any number is 1 if(n==0){ return 1; } else{ return x*pow(x, n-1); } }