Fibonnacci Next: Eratosthenes SieveUp: ExamplesPrevious: Examples

Fibonnacci

The Fibonnacci  machine prints the 50 first values of the Fibonnacci list.

public class Fibonnacci extends NrpMachine
{
  public Fibonnacci()
  {

    new Sum(this,"c0","c1","c2");

    new Const(this,"c3",1);
    new Const(this,"c4",0);
    new Follow(this,"c3","c2","c5");
    new Dup(this,"c5","c8","c6");

    new Dup(this,"c6","c7","c1");
    new Follow(this,"c4","c7","c0");
    new Out(this,"c8");
  }

  public static void main (String argv[])
  {
    Fibonnacci mach = new Fibonnacci();
    for (int i=0;i<50;i++){ mach.activation(mach); }
  }

}