here is my small challenge : | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 8

here is my small challenge :

Write a function that has a self-call, with n receiving an integer greater than 1 and typing all the binary numbers to a length of n from the smallest to the largest except for the numbers with zero consecutive digits For example, if n = 3 is printed: 010 011 101 110 111

17th Dec 2017, 8:31 AM
ABADA S
ABADA S - avatar
11 Answers
+ 5
yes there is no 00
17th Dec 2017, 9:48 AM
ABADA S
ABADA S - avatar
+ 5
there must not be any 00 in output just 11,010,110...etc
18th Dec 2017, 4:48 PM
ABADA S
ABADA S - avatar
+ 5
no once follow the basic condition , you must use self-call method
4th Jan 2018, 10:04 PM
ABADA S
ABADA S - avatar
+ 4
https://code.sololearn.com/cfJZSooz6Co0/?ref=app My try. Not too shabby I guess...
17th Dec 2017, 12:38 PM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
+ 4
thanks for all but there is no one use recall methods like string a(int x){some code and a(x-1)} for example
18th Dec 2017, 5:02 PM
ABADA S
ABADA S - avatar
+ 3
Here’s another version with a recursive method: https://code.sololearn.com/WB6YVa1Q4Re0/?ref=app
18th Dec 2017, 7:16 PM
Luc Hariman Randrianomenjanahary
Luc Hariman Randrianomenjanahary - avatar
17th Dec 2017, 10:42 AM
Luc Hariman Randrianomenjanahary
Luc Hariman Randrianomenjanahary - avatar
+ 2
When n = 5, these are invalid, right? 01001 10010 00111 11000 10001 etc...
17th Dec 2017, 12:10 PM
Kinshuk Vasisht
Kinshuk Vasisht - avatar
+ 2
https://code.sololearn.com/cTxG6cjdmuvP/?ref=app This is my try in C++ @ABADA S Now inside my function 'calcula(int n)' there is a call to 'calcula(n-1)'. Thanks for your comments. And now progressive... https://code.sololearn.com/chqWQkVWEhqS/?ref=app
17th Dec 2017, 5:06 PM
Enrique
+ 1
@ABADA S Shouldn't the program print 100 and 001 as well?
17th Dec 2017, 8:58 AM
Kinshuk Vasisht
Kinshuk Vasisht - avatar