write a java program pls solve it fast
1 11 111 1111 11111
Answers
Answered by
4
Input : 3
Output : 1 + 11 + 111 +....
Total sum is : 123
Input : 4
Output : 1 + 11 + 111 + 1111 +.....
Total sum is : 1234
Input : 7
Output : 1 + 11 + 111 + 1111 + 11111 +
111111 + 1111111 +.....
Total sum is : 1234567
singhpinki195:
byee
Answered by
14
class pt1
{
public static void main(String args[])
{
int n=7;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print("1");
}
System.out.println("");
}
}
}
Another way
class pattern
{
public static void main(String args[])
int a=0,p=1;
double s=0;
while(a<=6)
{
s=s+Math.pow(10,a);
p=(int) s;
a=a+1;
System.out.println(p);
}
}
}
Similar questions
Social Sciences,
6 months ago
Hindi,
6 months ago
CBSE BOARD X,
1 year ago
English,
1 year ago
Math,
1 year ago
English,
1 year ago