Java Program to print the following pattern | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Java Program to print the following pattern

7 14 15 28 29 30 31 56 57 58 59 60 61 62 63

26th Apr 2018, 1:06 PM
Jeevan M
Jeevan M - avatar
1 Answer
+ 2
//How about this? public class Program { public static void main(String[] args) { for(int i = 1, ii = 1; i <= 4; i++, ii *= 2) { for(int j = 0, n = 7 * ii; j < ii ; ++j, ++n) { System.out.print(n + " "); } System.out.println(""); } } } //Sorry it is dirty code.
26th Apr 2018, 1:34 PM
Disvolviĝo;
Disvolviĝo; - avatar