Computer Science, asked by debjitlovesjiya20, 11 months ago

write a java program pls solve it fast
1 11 111 1111 11111​

Answers

Answered by shooterap2003
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
debjitlovesjiya20: bolo
debjitlovesjiya20: bolo
debjitlovesjiya20: bolo
debjitlovesjiya20: bolo
debjitlovesjiya20: hey
debjitlovesjiya20: shivu
debjitlovesjiya20: inata pe oh raho
debjitlovesjiya20: on
Answered by shrutirhea
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);

}

}

}


debjitlovesjiya20: but u have tried thank u
shrutirhea: it is correct
shrutirhea: this one is easy
shrutirhea: the other one is
shrutirhea: class pattern
debjitlovesjiya20: okk
debjitlovesjiya20: by the way thanks
shrutirhea: try the other way also..both of them are correct
debjitlovesjiya20: okk
singhpinki195: hii
Similar questions