c-programming

Simple C programs
git clone git://git.laack.co/c-programming.git
Log | Files | Refs

fib-in-c.c (547B)


      1 #include <stdio.h>
      2 #include <stdint.h>
      3 
      4 unsigned long long calculate(unsigned long long p2, unsigned long long p1){
      5     return p2 + p1;
      6 }
      7 
      8 int main(){
      9 
     10     for(int i = 0; i < 10000; ++i){
     11         unsigned long long prior = 0;
     12         unsigned long long current = 1;
     13         for (int i = 0; i <= 90; ++i) {
     14             printf("%llu\n", current);
     15             unsigned long long int nc = calculate(prior, current);
     16             prior = current;
     17             current = nc;
     18         }
     19     }
     20 
     21 }
     22 
     23 // real    0m1.299s
     24 // user    0m0.280s
     25 // sys     0m1.017s