<commit_before>Fibbonacci with Binet's formula. Works only for small numbers. Breaks around 100.
https://stackoverflow.com/questions/9645193/calculating-fibonacci-number-accurately-in-c

:PROPERTIES:
:LEVEL: 0
:END:
#+BEGIN_SRC rust

fn main() {
    (0..100).for_each(|number: u32| {
        let value = binet(number as f64);

        println!("For {} Value is {}", number, value);
    })
}

fn binet(number: f64) -> u64 {
    let phi : f64 = (1_f64 + 5_f64.sqrt()) * 0.5;
    let fib = (phi.powf(number) - (1_f64 - phi).powf(number)) / 5_f64.sqrt();
    fib as u64
}

#+END_SRC<commit_msg>[katas] finacci move to org<commit_after>Some interesting ways to do computations of fibonacci.

Fibbonacci with Binet's formula. Works only for small numbers. Breaks around 100.
https://stackoverflow.com/questions/9645193/calculating-fibonacci-number-accurately-in-c


:PROPERTIES:
:LEVEL: 0
:END:
#+BEGIN_SRC rust

fn main() {
    (0..100).for_each(|number: u32| {
        let value = binet(number as f64);

        println!("For {} Value is {}", number, value);
    })
}

fn binet(number: f64) -> u64 {
    let phi : f64 = (1_f64 + 5_f64.sqrt()) * 0.5;
    let fib = (phi.powf(number) - (1_f64 - phi).powf(number)) / 5_f64.sqrt();
    fib as u64
}

#+END_SRC




DP tabulation.
:PROPERTIES:
:LEVEL: 0
:END:
#+BEGIN_SRC rust

fn fib(n: usize) -> usize {
    let mut table = vec![0; n+2];
    table[0] = 0;
    table[1] = 1;

    for i in 0..n {
        table[i + 1] += table[i];
        table[i + 2] += table[i];
        // in the end of this loop i + 1 will be finished, and we are starting to craft i + 2
    }

    table[n]
}

fn main() {
    println!("{}", fib(6));
}

#+END_SRC
{'fraction_non_alphanumeric': 0.16248506571087215, 'fraction_numerical': 0.05675029868578255, 'mean_word_length': 2.895348837209302, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4088721', 'n_tokens_mistral': 723, 'n_tokens_neox': 651, 'n_words': 173}