program to generate the following output :
5 55 555 5555 55555 555555
expecting wonderful answers from brainly computer master :)
Answers
Answered by
6
Solution:
The given problem is solved using language - Java.
import java.util.*;
public class Series{
public static void main(String s[]){
System.out.print("Enter n: ");
int n=(new Scanner(System.in)).nextInt();
for(int i=1,a=5;i<=n;i++,a=a*10+5)
System.out.print(a+" ");
}
}
Logic:
- Accept the limit from the user, say n.
- Initialise a = 5
- Display the value of a.
- Multiply a by 10 and add 5.
- Repeat steps 3 and 4 n times.
See attachment for output.
Attachments:
Answered by
6
anindyaadhikari13:
Nice approach.
Similar questions