Write a java program to generate the first n terms of the sequence without using multiplication. 1 2 4 8 16 32 ……….
Answers
Answered by
3
class Sequence
{
//function to display sequence
void displaySequence()
{
int i;
for(i = 1 ; i<=n ; i=i+i )
{
System.out.println(i);
}
}
}
{
//function to display sequence
void displaySequence()
{
int i;
for(i = 1 ; i<=n ; i=i+i )
{
System.out.println(i);
}
}
}
Similar questions