Need help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

Need help

I want to make this 1 10 101 but couldn't check the error here is my code plz help me correct https://code.sololearn.com/c498R3e0YWje/?ref=app

22nd Aug 2017, 8:27 AM
Aadi
7 Answers
+ 10
No error just replace b by 0 and a by 1 in system.out.print
22nd Aug 2017, 8:32 AM
P R
P R - avatar
+ 11
// next time, please indent your code for the love of cookies. public class NumberPattern { public static void main(String[] args) { for (int a = 1; a <= 5; a++) { for (int b = 1; b <= a; b++) { if(b%2 == 0) { System.out.print(0); } else { System.out.print(1); } } System.out.println(); } } }
22nd Aug 2017, 8:33 AM
Hatsy Rei
Hatsy Rei - avatar
+ 8
The question itself is confusing. Like give more examples like 1 10 101 1010 10101 101010 1010101 Because we need to know the patter. Your quedtion can also suggest: 1 10 101 1011 10111 101111 1011111
22nd Aug 2017, 8:38 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 7
Nice! The second one is easy too. (won't do as I am really bad at Java)
22nd Aug 2017, 8:41 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 3
got it
22nd Aug 2017, 8:34 AM
Aadi
+ 1
$ vengat that's fist one but u got me another idea to try for otherone
22nd Aug 2017, 8:39 AM
Aadi
+ 1
as I am 😂😀😀
22nd Aug 2017, 8:42 AM
Aadi