codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include <stdio.h> typedef unsigned long long ULL; void f(int n,ULL *a, ULL *b){ int i = 0; ULL t; *a = 1; *b = 1; while(n>>i>1) i++; while(i--){ t = *a; *a = t*t+5**b**b; *b = 2*t* *b; if(1<<i&n){ t = *a; *a = t+5**b; *b = t+*b; } } } int main(void){ int n; ULL a,b; for(n=1;n<100;n++){ f(n,&a,&b); printf("(1+√(5))^%d = %llu + %llu√(5)\n",n,a,b); } return 0; }
Private
[
?
]
Run code
Submit