wacallen01 wacallen01
  • 31-07-2022
  • Computers and Technology
contestada

Using any loop construct, write a java code to print the following:
1010101
10101
101
1​

Respuesta :

tonb
tonb tonb
  • 01-08-2022

Answer:

class Main {

 public static void main(String[] args) {

   for (int n = 0x55; n > 0; n /= 4) {

     System.out.println(Integer.toBinaryString(n));

   }

 }

}

Explanation:

Because the pattern is very regular, you can start with 0x55 (which is 0101 0101) and shift right 2 places everytime. Shift right 2 places is the same as dividing by 4.

Answer Link

Otras preguntas

different forms of a given gene are known as
Math Worksheet Questions? 1. A football field is 100 yards long. How many feet long is a football field? 2. In a roll of 50 pennies, 15 were minted before 1985.
____ is the power to make law and frame public policies.
factor m^2+12m+36 A. (M+6)^2 B. (M-6)^2 C. (M+36)^2 D. Can't be factored
Which sentence uses the correct form of the verb do? A. Her friend has done all of the decorations. B. Her friend has did all of the decorations. C. Her frie
Mark each statement if it was an outcome of the Peloponnesian War. A. The Persians conquered Greece and put Sparta in charge. B. Athenian political power ended.
SOMEONE HELP ME WITH THIS PROOF
Ben smiled as the sun's rays shimmered through the window and lit up the room drawing open the curtains. What is the misplaced modifier in this sentence? A. l
Continue the pattern 3,5,8,10 _ _ _
Which sentence does not contain any errors in comma usage? A. This long tiring and sweaty hike is no fun any more. B. This is the best, and most interesting tri