Skip to content

Commit

Permalink
sparse-Fibonacci
Browse files Browse the repository at this point in the history
  • Loading branch information
witek-formanski committed Oct 30, 2023
1 parent 405d78b commit 6a5f919
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 10 deletions.
45 changes: 35 additions & 10 deletions src/count_sparse_numbers.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,42 @@
nearest power of two (less than n):
32dec = 100000bin
100000 - jaka potęga dwójki, tyle zer na końcu
8:
100000
100001
100010
100100
100101
101000
101001
101010
5:
10000
10001
10010
10100
10101
3:
1000
1001
1010
2:
100
101
1:
10
1:
1
Fibonacci!
fib(n+2) - 1 = fib(n+1) + ...?
10 0001
10 0010
10 0100
10 1000
1010 01
1010 10
10010 1
*/

int nearest_lower_pow_of_two(int n) {}
Expand Down
8 changes: 8 additions & 0 deletions src/count_sparse_numbers_brute.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,13 @@ int main() {

printf("%d", count_sparse_numbers_brute(n));

// surprise - Fibonacci!
// for (int i = 0; i < 13; i++) {
// printf("count_sparse(%d) \t- count_sparse(%d) \t= %d\n",
// 1 << (i + 1),
// 1 << (i),
// count_sparse_numbers_brute(1 << (i + 1)) - count_sparse_numbers_brute(1 << (i)));
// }

return 0;
}

0 comments on commit 6a5f919

Please sign in to comment.