+ 1
Next number generator with two digits
eg1: 3 and 4 are the two digits then the next number generation is 34,43,334,343,344,434,....... eg2: 5 and 0 are the two digits then the next number generation is 50,500,505,550,.......
4 Réponses
+ 1
thanks @ michal I got ur logic but I don't want same digits repeating like 11 111 1111
+ 1
thank you Michal got it
0
what is the problem ?
this generator is quite simple if you think of it as of binary counter:
0 - 0
1 - 1
2 - 10
3 - 11
4 - 100
5 - 101
6 - 110
7 - 111
8 - 1000
9 - 1001
10 - 1010
11 - 1011
etc..
then just replace '1' and '0' with your symbols
0
while counting you can test for the value of power(2,i)-1 (it's 11 111 1111 11111 value)
then remove the value, increment i
pseudocode:
i = 0;
value = 0;
loop {
if (value == power(2,i)-1) i++;
else youhavebinvalue;
value++;
}
i think it's quite fast algorithm