0

Write a JAVA code to represent the following series: 1,2,4,8,16,32,64 by using do –while.

I need the result

25th Feb 2021, 12:45 AM
As0
As0 - avatar
11 Answers
+ 6
Let <i> = 1 Print <i> Begin loop Multiply <i> by 2 Print ", " followed by <i> While <i> < 64 As @visph suggested, use System.out.print() for printing values rather than System.out.println(). Try to implement this into a code And please put Java in your thread's tags above (where you wrote 1) ☝
25th Feb 2021, 2:00 AM
Ipang
+ 2
by using print instead of println (print line: add a new line char at end)
25th Feb 2021, 12:58 AM
visph
visph - avatar
+ 2
you must also add some space or separator between numbers ;)
25th Feb 2021, 12:58 AM
visph
visph - avatar
+ 1
You must try and show your attempt before we can help you
25th Feb 2021, 12:51 AM
Michal Doruch
+ 1
tips: it's powers of two serie
25th Feb 2021, 12:55 AM
visph
visph - avatar
+ 1
public class Main { public static void main(String[] args) { int i = 1; int mul=1; do { System.out.println(mul); mul*=2; i++; } while (i < 8); } }
25th Feb 2021, 12:55 AM
As0
As0 - avatar
+ 1
Please read the rules before posting https://www.sololearn.com/Discuss/1316935/?ref=app
25th Feb 2021, 12:55 AM
Pieter Edwards
Pieter Edwards - avatar
0
How do I make it in a series I can do it only vertically
25th Feb 2021, 12:56 AM
As0
As0 - avatar
0
Can you write it in code so that the picture is clear to me?
25th Feb 2021, 1:00 AM
As0
As0 - avatar
0
you should try yourself to be able to learn...
25th Feb 2021, 1:01 AM
visph
visph - avatar
0
Well, thank you, brother
25th Feb 2021, 1:02 AM
As0
As0 - avatar