Saturday, June 28, 2025

THE 32-BIT BUG

/****************************************************************************************************
 * date         :JUNE 28, 2025
 * author       :A.E.
 * prog_name    :FIBONACCI
 * 
 * filename:    :fibonacci.rs
 * 
 * comment      :   The CPU in a virtualization is so limited, my hardware has capability to do the
 *              task but the virualization limits the CPU speed and it takes forever to compute
 *              even the 40 Fibonacci sequence it is a large number but in this program I just
 *              u32 (unsigned 32-bit with range of 0-2,147,483,647) data type it has decent large 
 *              number capacity but in this modern day computing it is just piece of shit
 *              It gets error in 47TH Fibinacci sequence 'cause it reach its limit  you could
 *              change into 64-bit to accept larger number.
 *
 *              The 32-bit integer is the sole culprit that's why in year 2038 our cpu time must be
 *              fixed or else it will gets error because the unix time started counting seconds
 *              from January 1, 1971 and will last until January 19, 2038 that if there is  Y2K bug
 *              in year 200 there will be Y2K38 in 1938. There are a lots of system will be
 *              affected even the timestamps of some File System Existing today we have time but it
 *              will surely cost money, because of that. Even the old satellite will be affected we
 *              overlook those bug, and everything now is starting to migrate 64bit in system which
 *              people nowadays considered it overkill
 *
 *              And it is also the culprit that's why we even use all the IPv4 addresses in the world
 *              because it also tailored in a 32-bit data type system.
 *
 *              That why IPv6 is there can handle billions of hosts but it could be a problem for
 *              the people of future. Back then nobody thinks that 32-bit will never be enough.
 *              
 *              We are all thinking that 64-bit is enough but the future people I would like to
 *              thinkit will not be enough for them. Back in 1960's 5 MB (Megabytes) is insane size o
 *              f storage nobody back then think it will be full. But today a single picture taken from 
 *              a cellphone  camera can have a size of 20 Megabytes or more.
 *
 *
 * ***************************************************************************************************/


use std::io;
use std::io::Write;

fn fibonacci(n: u32) -> u32 {
   
    match n {
        0 => 1,
        1 => 1,
        _=> fibonacci(n-1) + fibonacci(n-2),
    }
}



fn main(){
    println!("Fibonacci generator");
    println!("Type \"quit\" to exit");


    loop{
        let mut n = String::new();

        print!("Enter positive integer: ");
       
        io::stdout().flush().unwrap(); 
        io::stdin().read_line(&mut n).expect("Failed to read Line");
        println!();
        
        if n.trim() == "quit" { break; }

        let n: u32 = match n.trim().parse() {
            Ok(num) => num,
            Err(_) => continue,
        };

        println!("{}", fibonacci(n));

    }
}