Display the Series 2 9 28 65 …. n
Logic : (1^3)+1 = 1+1 =2
(2^3)+1 = 8+1 =9
(3^3)+1 = 27+1 =28
(4^3)+1 = 64+1 =65
(5^3)+1 = 125+1 =126
(6^3)+1 = 216+1 =217
(3^3)+1 = 27+1 =28
(4^3)+1 = 64+1 =65
(5^3)+1 = 125+1 =126
(6^3)+1 = 216+1 =217
import java.util.*;
class Series_2_9_28_65
{
public static void main(String args[])
{
int i, n,num=0;
Scanner sc=new Scanner(System.in);
System.out.println("Enter the terms of Series = ");
n=sc.nextInt();
for(i=1;i<=n;i++)
{
num=(int)(Math.pow(i,3)+1);
System.out.print(num+"
");
}
}
}
Sir bohot aacha tarika hai
ReplyDelete