-----Java Challenge-----
Q) Wap in Java to print the following pattern :
0,1,1,32,243,3125,32768....Nth term
Answers
Answer:
Hello pls thanks my answers
Q) Cober
ans) As a proven leader in the industry, Cober has strong strategic partnerships with our clients. We deliver effective content through print, digital, interactive and integrated services that focus on strategy and metrics. The core of our business has been founded professionally in the print industry for the past 99 years.
Required Answer:-
Correct Question:
- Write a program in Java to print the following series.
Solution:
Here comes the program.
import java.util.*;
public class Series {
public static void main(String[] args) {
int n, a=1, b=0, c=0, i, d;
Scanner sc=new Scanner(System.in);
System.out.print("Enter n - ");
n=sc.nextInt();
for(i=1;i<=n;i++) {
d=(int)(Math.pow(c, 5));
System.out.print(d+" ");
c=a+b;
a=b;
b=c;
}
sc.close();
}
}
Explanation:
Fibonacci series is given as,
0 1 1 2 3 5 8 13....
If we raise each term to the power 5, we get,
0 1 1 32 243 3125 32768....
This series is just a modified version of Fibonacci series. We will find nth Fibonacci series, raise it's value to the power 5 and display it.
See the attachment for output ☑.