Computer Science, asked by shourya2268, 1 year ago

write a program to print the following:-. 1,11,111,1111,11111...... for n-times

Answers

Answered by Manindersingh11
10
in python.

n=5
for i in range(n):
print('1'*i,end=',')
Answered by tripathiakshita48
0

Now let us write the program to print the sequence for n-times in Java,

import java.util.Scanner;

public class Series  

{

public static void main(String args[])

{

Scanner sc = new Scanner(System.in);

System.out.print("Enter the number of terms: ");

int n = sc.nextInt();

int s = 0, c;                                          // s for terms of series, c for n terms

for (c = 1; c <= n; c++)                          // To generate n terms

{

s = s * 10 + 1;

 System.out.print(s + " ");

 }                                                           //for  ends

}

}

Now let us see the output of the program,

Output:

Enter the number of terms: 7

1, 11, 111, 1111, 11111, 111111, 1111111......

For more such questions on Programming: https://brainly.in/question/29992989

#SPJ3

Similar questions