answersLogoWhite

0


Best Answer

To print the given sequence in Java, you can use a loop to iterate through each number and print it the corresponding number of times. Here's an example code snippet to achieve this:

public class NumberSequence {
    public static void main(String[] args) {
        int[] numbers = {5, 4, 3, 2, 1};
        
        for (int num : numbers) {
            for (int i = num; i >= 1; i--) {
                System.out.print(num);
            }
            System.out.print(" ");
        }
    }
}

This code will output: 55555 4444 333 22 1

User Avatar

ProfBot

3d ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

You can do this with a nested loop:

public static void main(String[] args){

for(int i=5, i>0, i--){

for(int j=i, j>0; j--)

System.out.print(i);

System.out.print(' ');

}

}

The outer loop decrements the integer that you are printing and the inner loop will print the integer the number of times equal to its value.

This answer is:
User Avatar

User Avatar

Wiki User

9y ago

for (int x=5; 0<x; --x){

for (int y=0; y<x; ++y){

System.out.print (x);

}

System.out.print (' ');

}

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you write 55555 4444 333 22 1 in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you write 55555 4444 333 22 1 in php?

This is one of possible solutions:


What is the sequence of 122333444455555?

Each digit is repeated the number of times equal to its value. 1 22 333 4444 55555 666666 7777777 88888888 999999999


1 22 333 4444 55555 i need a java program that generates a triangle with these numbers?

Implement this method: public static void makeTriangle(int limit) { int count = 0; for(int i = 1; i &lt;= limit; i++) { count = i; while(count &gt; 0) { System.out.print(i); count--; } System.out.println(); } }


What is 4444 divided by 333 equals?

13.3453


Write a c program to print the following output using for loop 1 2 2 333 4444 55555?

int main() { int i,j,sum,k; for(i=1;i&lt;=5;i++) { k=1; sum =0; for(j=1;j&lt;=i;j++) { sum = sum+(i*k); k=k*10; } cout&lt;&lt; sum; cout&lt;&lt; "\n"; } }


What is Margaret Peterson haddixs phone number?

222 333 4444


C program to print 1 12 123 1234?

#include &lt;stdio.h&gt; int main (void) { puts ("1 22 333 4444 55555"); return 0; }


Write a c sharp program to print 1 22 333 4444 55555 as right angle trianglr?

using System;namespace RightAngleTraingle{class Program{static void Main(string[] args){for (int x = 1; x


What does the brain teaser 4444 mean?

it means the same thing as 333 or 55555In other words, what is there about 4444 that makes it "interesting".The answer is that it is composed of the digit 4, 4 times.


Express the sum of 4444 km and 333 km using the correct number of significant digits?

4,777 km


How do you solve graham and moser number?

22^333^444^55555^666666^7777777^88888888^999999999 repeat this step 4096 times


How would you write a C program loop that outputs the values 4444 333 22 1?

int i = 4;while (i&gt;0) { for (int n=0; n&lt;i; ++n) { printf ("%d", i); } printf (" "); } printf ("\n");