Given a positive integer n, the following rules will always create a sequence that ends with 1, called the hailstone sequence: If n is even, divide it by 2 If n is odd, multiply it by 3 and add 1 (i.e. 3n +1) Continue until n is 1 Write a function that takes an integer n as input and prints the hailstone sequence starting with the integer entered. Format the output so that ten integers, each separated by a tab character (\t), are printed per line. The output format can be achieved as follows: System.out.print(n + “\t”); Ex: If the input is: 25 the output is: 25 76 38 19 58 29 88 44 22 11 34 17 52 26 13 40 20 10 5 16 8 4 2 1 Note: you don’t need to implement a main method.
Blog
Potassium metal reacts violently when added to water accordi…
Potassium metal reacts violently when added to water according to the balanced equation: 2 K(s) + 2 H2O(l) → 2 KOH(aq) + H2(g) How many moles of H2O are needed to reactcompletely with 7.54 mol of K? DO NOT INCLUDE THE UNIT IN YOUR ANSWER. (Neatly write your calculation on a scratch paper, show your work slowly on the webcam before you submit the test. Take a photo of your work, and submit it on Final Exam Work assignment on the module.)
What coefficient is placed in front of O2 to complete the ba…
What coefficient is placed in front of O2 to complete the balancing of the following equation? C5H8 + ? O2 → CO2 + H2O
How many carbon atoms are in 3.85 mol of carbon?
How many carbon atoms are in 3.85 mol of carbon?
Consider the reaction, C2H4(g) + H2(g) —> C2H6(g), where ∆…
Consider the reaction, C2H4(g) + H2(g) —> C2H6(g), where ∆H= –137 kJ. How much heat is released when 3.60 mol of C2H4reacts? DO NOT INCLUDE THE UNIT IN YOUR ANSWER. (Neatly write your calculation on a scratch paper, show your work slowly on the webcam before you submit the test. Take a photo of your work, and submit it on Final Exam Work assignment on the module.)
Which of the following is the closest value for the bond ang…
Which of the following is the closest value for the bond angle around the oxygen atom in H2O?
Given that 1 inch = 2.54 cm, 1 cm3 is equal to …
Given that 1 inch = 2.54 cm, 1 cm3 is equal to in3.
Which of the following number has the largest number of sign…
Which of the following number has the largest number of significant figures? A) 0.000345 B) 0.1030 C) 1.3000 D) 10.0 E) 0.01500
Which statement describing atoms is FALSE?
Which statement describing atoms is FALSE?
What would happen to a red blood cell when it is placed in a…
What would happen to a red blood cell when it is placed in a hypertonic solution?