Top
Back: D.2.2.6 factorial
Forward: D.2.2.8 kmemory
FastBack: D. SINGULAR libraries
FastForward: E. Release Notes
Up: D.2.2 general_lib
Top: Singular 2-0-4 Manual
Contents: Table of Contents
Index: F. Index
About: About This Document

D.2.2.7 fibonacci

Procedure from library general.lib (see general_lib).

Usage:

fibonacci(n); n,p integers

Return:

fibonacci(n): nth Fibonacci number, f(0)=f(1)=1, f(i+1)=f(i-1)+f(i)
- computed in characteristic 0, of type string
fibonacci(n,p): f(n) computed in characteristic 0 or prime(p)
- of type number if a basering is present and p=0=char(basering) or if prime(p)=char(basering)
- of type string else

Example:

 
LIB "general.lib";
fibonacci(42); "";             //f(42) of type string (as long integer)
→ 267914296
→ 
ring r = 2,x,dp;
number b = fibonacci(42,2);    //f(42) of type number, computed in r
b;
→ 0

See also: prime.


Top Back: D.2.2.6 factorial Forward: D.2.2.8 kmemory FastBack: D. SINGULAR libraries FastForward: E. Release Notes Up: D.2.2 general_lib Top: Singular 2-0-4 Manual Contents: Table of Contents Index: F. Index About: About This Document
            User manual for Singular version 2-0-4, October 2002, generated by texi2html.