Run Code  | API  | Code Wall  | Users  | Misc  | Feedback  | Login  | Theme  | Privacy  | Patreon 

количество 1 и 0 в последовательности чисел до n

Language: Layout:
- ] Show input
Absolute running time: 0.1 sec, cpu time: 0.06 sec, memory peak: 6 Mb, absolute service time: 0,12 sec 
edit mode |  history  | discussion
Hello, world!
Введите число:
k= 0 s1= 0 s0= 0
k= 1 s1= 1 s0= 0
k= 2 s1= 2 s0= 1
k= 3 s1= 4 s0= 1
k= 4 s1= 5 s0= 3
k= 5 s1= 7 s0= 4
k= 6 s1= 9 s0= 5
k= 7 s1= 12 s0= 5
k= 8 s1= 13 s0= 8
k= 9 s1= 15 s0= 10
k= 10 s1= 17 s0= 12
For n= 10 there are 12 "0" and 17 "1"
|"1" - "0"|= 5