SlideShare une entreprise Scribd logo
1  sur  2
on java
The following method is an example of what? What are the two components required for these
types of methods?
Solution
The given program is an example of recursion method in java.
The factorial of a number be found using recursion also. The base case can be taken as the
factorial of the number 0 or 1, both of which are 1. The factorial of some number n is that
number multiplied by the factorial of (n-1). Mathematically,
factorial ( 0 ) = 1
factorial ( n ) = n * factorial ( n - 1 )
Given below is a program which calculates the factorial of 7 using recursion.the components
required for this are as follows:
public class Factorial { // Here the class name is taken as Factorial
public static void main(String[] args) {
int n = 7; // initializing value of n
int result = factorial(n); // factorial value is stored in result
System.out.println("The factorial of 7 is " + result); // printing the factorial value of 7
}
public static long factorial(int n) {
if (n == 0) {
return 1;
} else {
return n * factorial(n - 1);
}
}
}
on java The following method is an example of what- What are the two c.docx

Contenu connexe

Similaire à on java The following method is an example of what- What are the two c.docx

Reaction StatisticsBackgroundWhen collecting experimental data f.pdf
Reaction StatisticsBackgroundWhen collecting experimental data f.pdfReaction StatisticsBackgroundWhen collecting experimental data f.pdf
Reaction StatisticsBackgroundWhen collecting experimental data f.pdf
fashionbigchennai
 
9781439035665 ppt ch02
9781439035665 ppt ch029781439035665 ppt ch02
9781439035665 ppt ch02
Terry Yoast
 
SeriesTester.classpathSeriesTester.project SeriesT.docx
SeriesTester.classpathSeriesTester.project  SeriesT.docxSeriesTester.classpathSeriesTester.project  SeriesT.docx
SeriesTester.classpathSeriesTester.project SeriesT.docx
lesleyryder69361
 
E2 – Fundamentals, Functions & ArraysPlease refer to announcements.docx
E2 – Fundamentals, Functions & ArraysPlease refer to announcements.docxE2 – Fundamentals, Functions & ArraysPlease refer to announcements.docx
E2 – Fundamentals, Functions & ArraysPlease refer to announcements.docx
shandicollingwood
 
9781111530532 ppt ch07
9781111530532 ppt ch079781111530532 ppt ch07
9781111530532 ppt ch07
Terry Yoast
 
9781111530532 ppt ch07
9781111530532 ppt ch079781111530532 ppt ch07
9781111530532 ppt ch07
Terry Yoast
 
9781439035665 ppt ch05
9781439035665 ppt ch059781439035665 ppt ch05
9781439035665 ppt ch05
Terry Yoast
 
9781111530532 ppt ch13
9781111530532 ppt ch139781111530532 ppt ch13
9781111530532 ppt ch13
Terry Yoast
 
Lecture 5: Functional Programming
Lecture 5: Functional ProgrammingLecture 5: Functional Programming
Lecture 5: Functional Programming
Eelco Visser
 

Similaire à on java The following method is an example of what- What are the two c.docx (20)

9. DBMS Experiment Laboratory PresentationPPT
9. DBMS Experiment Laboratory PresentationPPT9. DBMS Experiment Laboratory PresentationPPT
9. DBMS Experiment Laboratory PresentationPPT
 
Method overloading, recursion, passing and returning objects from method, new...
Method overloading, recursion, passing and returning objects from method, new...Method overloading, recursion, passing and returning objects from method, new...
Method overloading, recursion, passing and returning objects from method, new...
 
Reaction StatisticsBackgroundWhen collecting experimental data f.pdf
Reaction StatisticsBackgroundWhen collecting experimental data f.pdfReaction StatisticsBackgroundWhen collecting experimental data f.pdf
Reaction StatisticsBackgroundWhen collecting experimental data f.pdf
 
Ase02.ppt
Ase02.pptAse02.ppt
Ase02.ppt
 
Chapter 13
Chapter 13Chapter 13
Chapter 13
 
Java conceptual learning material
Java conceptual learning materialJava conceptual learning material
Java conceptual learning material
 
Adaptive Training of Radial Basis Function Networks Based on Cooperative
Adaptive Training of Radial Basis Function Networks Based on CooperativeAdaptive Training of Radial Basis Function Networks Based on Cooperative
Adaptive Training of Radial Basis Function Networks Based on Cooperative
 
java_lect_03-2.ppt
java_lect_03-2.pptjava_lect_03-2.ppt
java_lect_03-2.ppt
 
9781439035665 ppt ch02
9781439035665 ppt ch029781439035665 ppt ch02
9781439035665 ppt ch02
 
C code examples
C code examplesC code examples
C code examples
 
SeriesTester.classpathSeriesTester.project SeriesT.docx
SeriesTester.classpathSeriesTester.project  SeriesT.docxSeriesTester.classpathSeriesTester.project  SeriesT.docx
SeriesTester.classpathSeriesTester.project SeriesT.docx
 
E2 – Fundamentals, Functions & ArraysPlease refer to announcements.docx
E2 – Fundamentals, Functions & ArraysPlease refer to announcements.docxE2 – Fundamentals, Functions & ArraysPlease refer to announcements.docx
E2 – Fundamentals, Functions & ArraysPlease refer to announcements.docx
 
9781111530532 ppt ch07
9781111530532 ppt ch079781111530532 ppt ch07
9781111530532 ppt ch07
 
9781111530532 ppt ch07
9781111530532 ppt ch079781111530532 ppt ch07
9781111530532 ppt ch07
 
9781439035665 ppt ch05
9781439035665 ppt ch059781439035665 ppt ch05
9781439035665 ppt ch05
 
Functions
FunctionsFunctions
Functions
 
9781111530532 ppt ch13
9781111530532 ppt ch139781111530532 ppt ch13
9781111530532 ppt ch13
 
functions.pptx
functions.pptxfunctions.pptx
functions.pptx
 
Lecture 5: Functional Programming
Lecture 5: Functional ProgrammingLecture 5: Functional Programming
Lecture 5: Functional Programming
 
Control Structures: Part 1
Control Structures: Part 1Control Structures: Part 1
Control Structures: Part 1
 

Plus de tkathryn

A city is considering reidevelopment of existing 500 ha of industrial.docx
A city is considering reidevelopment of existing 500 ha of industrial.docxA city is considering reidevelopment of existing 500 ha of industrial.docx
A city is considering reidevelopment of existing 500 ha of industrial.docx
tkathryn
 
On January 1- 2010 Manovic LTD paid HULU $120 for internet movie acces.docx
On January 1- 2010 Manovic LTD paid HULU $120 for internet movie acces.docxOn January 1- 2010 Manovic LTD paid HULU $120 for internet movie acces.docx
On January 1- 2010 Manovic LTD paid HULU $120 for internet movie acces.docx
tkathryn
 

Plus de tkathryn (20)

A concise answer would suffice- Thank you- short Videos about special.docx
A concise answer would suffice- Thank you- short Videos about special.docxA concise answer would suffice- Thank you- short Videos about special.docx
A concise answer would suffice- Thank you- short Videos about special.docx
 
A company has purchased inventory and receives an invoice that indicat.docx
A company has purchased inventory and receives an invoice that indicat.docxA company has purchased inventory and receives an invoice that indicat.docx
A company has purchased inventory and receives an invoice that indicat.docx
 
A company uses a weighted average perpetual inventory system- August.docx
A company uses a weighted average perpetual inventory system-  August.docxA company uses a weighted average perpetual inventory system-  August.docx
A company uses a weighted average perpetual inventory system- August.docx
 
A company reissued at $20 per share 100 shares of treasury stock that.docx
A company reissued at $20 per share 100 shares of treasury stock that.docxA company reissued at $20 per share 100 shares of treasury stock that.docx
A company reissued at $20 per share 100 shares of treasury stock that.docx
 
A cockroach of mass m lies on the rim of a uniform disk of mass 5-00 m.docx
A cockroach of mass m lies on the rim of a uniform disk of mass 5-00 m.docxA cockroach of mass m lies on the rim of a uniform disk of mass 5-00 m.docx
A cockroach of mass m lies on the rim of a uniform disk of mass 5-00 m.docx
 
A city is considering reidevelopment of existing 500 ha of industrial.docx
A city is considering reidevelopment of existing 500 ha of industrial.docxA city is considering reidevelopment of existing 500 ha of industrial.docx
A city is considering reidevelopment of existing 500 ha of industrial.docx
 
On January 1- 2014- the Gamekeeper On January 1- 2014- the Gamekee.docx
On January 1- 2014- the Gamekeeper     On January 1- 2014- the Gamekee.docxOn January 1- 2014- the Gamekeeper     On January 1- 2014- the Gamekee.docx
On January 1- 2014- the Gamekeeper On January 1- 2014- the Gamekee.docx
 
On January 1- 2014- The Timber Company acquired a 12- interest in the.docx
On January 1- 2014- The Timber Company acquired a 12- interest in the.docxOn January 1- 2014- The Timber Company acquired a 12- interest in the.docx
On January 1- 2014- The Timber Company acquired a 12- interest in the.docx
 
On January 1- 2014- Frick Company purchased 10-000 shares of the stock.docx
On January 1- 2014- Frick Company purchased 10-000 shares of the stock.docxOn January 1- 2014- Frick Company purchased 10-000 shares of the stock.docx
On January 1- 2014- Frick Company purchased 10-000 shares of the stock.docx
 
On January 1- 2013- Randolph signed a two year lease to rent office sp.docx
On January 1- 2013- Randolph signed a two year lease to rent office sp.docxOn January 1- 2013- Randolph signed a two year lease to rent office sp.docx
On January 1- 2013- Randolph signed a two year lease to rent office sp.docx
 
On January 1- 2011- Mulcahy Manufacturing Inc-- a newly formed corpora.docx
On January 1- 2011- Mulcahy Manufacturing Inc-- a newly formed corpora.docxOn January 1- 2011- Mulcahy Manufacturing Inc-- a newly formed corpora.docx
On January 1- 2011- Mulcahy Manufacturing Inc-- a newly formed corpora.docx
 
On January 1- 2011- Bishop Company issued 10- bonds dated January 1- 2.docx
On January 1- 2011- Bishop Company issued 10- bonds dated January 1- 2.docxOn January 1- 2011- Bishop Company issued 10- bonds dated January 1- 2.docx
On January 1- 2011- Bishop Company issued 10- bonds dated January 1- 2.docx
 
On January 1- 2010 Manovic LTD paid HULU $120 for internet movie acces.docx
On January 1- 2010 Manovic LTD paid HULU $120 for internet movie acces.docxOn January 1- 2010 Manovic LTD paid HULU $120 for internet movie acces.docx
On January 1- 2010 Manovic LTD paid HULU $120 for internet movie acces.docx
 
On December 31-2011- the shareholders-' equity section of the balance.docx
On December 31-2011- the shareholders-' equity section of the balance.docxOn December 31-2011- the shareholders-' equity section of the balance.docx
On December 31-2011- the shareholders-' equity section of the balance.docx
 
On December 31- 2012 Revel Corporation-'s balance sheet reported the f.docx
On December 31- 2012 Revel Corporation-'s balance sheet reported the f.docxOn December 31- 2012 Revel Corporation-'s balance sheet reported the f.docx
On December 31- 2012 Revel Corporation-'s balance sheet reported the f.docx
 
On December 31- 2008- Nolte Co- is in financial difficulty and cannot.docx
On December 31- 2008- Nolte Co- is in financial difficulty and cannot.docxOn December 31- 2008- Nolte Co- is in financial difficulty and cannot.docx
On December 31- 2008- Nolte Co- is in financial difficulty and cannot.docx
 
On February 12- Addison- Inc- purchased 6-000 shares of Lucas Company.docx
On February 12- Addison- Inc- purchased 6-000 shares of Lucas Company.docxOn February 12- Addison- Inc- purchased 6-000 shares of Lucas Company.docx
On February 12- Addison- Inc- purchased 6-000 shares of Lucas Company.docx
 
On December 1- 2014- Mr- and Mrs- Tyler purchased four tickets for a N.docx
On December 1- 2014- Mr- and Mrs- Tyler purchased four tickets for a N.docxOn December 1- 2014- Mr- and Mrs- Tyler purchased four tickets for a N.docx
On December 1- 2014- Mr- and Mrs- Tyler purchased four tickets for a N.docx
 
On December 1- 2011- Joseph Company- a U-S- company- entered into a th.docx
On December 1- 2011- Joseph Company- a U-S- company- entered into a th.docxOn December 1- 2011- Joseph Company- a U-S- company- entered into a th.docx
On December 1- 2011- Joseph Company- a U-S- company- entered into a th.docx
 
on Stre - DH SolutionThe strength of a nucleophile depends on how easi.docx
on Stre - DH SolutionThe strength of a nucleophile depends on how easi.docxon Stre - DH SolutionThe strength of a nucleophile depends on how easi.docx
on Stre - DH SolutionThe strength of a nucleophile depends on how easi.docx
 

Dernier

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 

Dernier (20)

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 

on java The following method is an example of what- What are the two c.docx

  • 1. on java The following method is an example of what? What are the two components required for these types of methods? Solution The given program is an example of recursion method in java. The factorial of a number be found using recursion also. The base case can be taken as the factorial of the number 0 or 1, both of which are 1. The factorial of some number n is that number multiplied by the factorial of (n-1). Mathematically, factorial ( 0 ) = 1 factorial ( n ) = n * factorial ( n - 1 ) Given below is a program which calculates the factorial of 7 using recursion.the components required for this are as follows: public class Factorial { // Here the class name is taken as Factorial public static void main(String[] args) { int n = 7; // initializing value of n int result = factorial(n); // factorial value is stored in result System.out.println("The factorial of 7 is " + result); // printing the factorial value of 7 } public static long factorial(int n) { if (n == 0) { return 1; } else { return n * factorial(n - 1); } } }