some new things, mostly not working or finished
This commit is contained in:
22
fib/sfib.c
Normal file
22
fib/sfib.c
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <stdio.h>
|
||||
typedef unsigned long long U;
|
||||
|
||||
U fib(int n) {
|
||||
if (n < 2) return n;
|
||||
U a = 1, b = 1, c = 1, d = 0, x = 1, y = 0, z = 0, w = 1, t;
|
||||
while (n) {
|
||||
if (n & 1) {
|
||||
t = x * a + y * c; y = x * b + y * d; x = t;
|
||||
t = z * a + w * c; w = z * b + w * d; z = t;
|
||||
}
|
||||
t = a * a + b * c; b = a * b + b * d; a = t;
|
||||
t = c * a + d * c; d = c * b + d * d; c = t;
|
||||
n >>= 1;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv[]) {
|
||||
for (int i = 0;i < int(argv);i++) printf("%llu ", fib(i));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user