write the programs in java to display the first 10 numbers of the series 4,8,16,32............n
Answers
Answered by
19
Answer:
Public class Demo
{
public static void main(String args[])
{
for(int i = 1; i < 8; i++)
System.out.print((int)Math.pow(2, i)+" ");
}
}
Hope this helps!
Answered by
6
By using scanner:-
import java.util.*;
public class Series
{
public static void main(String args[])
{
Scanner sc = new Scanner (System.in);
System.out.print ("Enter a number:");
int n=sc.nextInt();
int j=0;
for( int i=2; i<=n; i++)
{
j= Math.pow(2,i);
System.out.println( j + " , " );
}
}
}
Similar questions