Computer Science, asked by arijitdeb59gmailcom, 1 year ago

write a program in java to display the series(not the sum).
1+11+111+1111..…...upto n terms​


rakeshchennupati143: if you liked it mark as brainliest
rakeshchennupati143: why did you report my answer it was perfect
arijitdeb59gmailcom: i by mistake reported it

Answers

Answered by rakeshchennupati143
19

Program:

import java.util.*;

public class Main{

     public static void main(String args[]){

           System.out.print("Enter nth term : ");

           Scanner sc = new Scanner(System.in);

           int j=1,n = sc.nextInt();

           System.out.print("1");

           for(int i = 1 ; i < n ; i++ ){

                 j = (j*10)+1;

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

           }

     }

}

Output:

Enter nth term : 5

1+11+111+1111+1111

Explanation:

  • i took nth term and started for loop in the range from 1 to nth term
  • and first i calculated j value as j = (j*10)+1 which will give series of 1,11,111,1111,1111.....so on
  • so i printed each number for each iteration for next iteration the ja value will be 11 and for next 111 so like that i printed up to the nth term

----Hope you liked my program,if you liked is mark as as brainliest, it would really help me.  :)

Answered by nishasantosh551
0

Explanation:

do u play mlbb

hfvvb

hgnb

Attachments:
Similar questions