
function infini() {
  this.k=3;
  this.lg=100;
  this.rmini=1;
  this.tab=new Array();
  this.origines=new Array();
  this.raisons=new Array();
  this.dtab=new Array();
  this.current=0;


  function set() {
    this.lg=parseInt(document.f3.lg.value);
    this.k=parseInt(document.f3.k.value);
    this.rmini=parseInt(document.f3.r.value);
    
  }
  this.set = set;

  function suivant() {
    var i, ori, d, test;
    for(ori=0;ori<=this.lg && this.tab[ori]!=void(0); ori++) ;
    if(ori<= this.lg) {
      this.origines[this.current] = ori;
      test = true
      for(d= this.rmini; test ; ) {
        test = false 
        while(this.dtab[d] != void(0)) d++;
        for(i=0;!test && i<this.k;i++) 
           if(this.tab[ori+i*d] != void(0)) {
             test = true;
             d++;
           }
      }
      
      this.raisons[this.current] = d
      this.dtab[d]=1
      for(i=0;i<this.k;i++) {
        this.tab[ori+i*d] = this.current;
      }
      this.current++
      return true
    }
    return false;
  }
  this.suivant=suivant;

  function affiche() {
    var s="Pavage :\n";
    for(i=0;i<=this.lg;i++) {
      s += this.tab[i];
      if(i<this.lg)
        s += " ";
    }
    s += " etc.\n";
    s +="Raisons :\n"
    for(i=0;i<this.current;i++) {
      s += this.raisons[i];
      if(i<this.lg)
        s += " ";
    }
    s += " etc.\n";
    s +="Progressions :\n";
    for(i=0;i<this.current;i++) {
      s +="("
      for(j=0;j<this.k;j++) {
        s +=this.origines[i]+j*this.raisons[i];
        if(j<this.k-1)
          s +=","
        else
          s+=") "
      }
    }
    s += " etc.\n"
    s +="Origines :\n";
    for(i=0;i<this.current;i++) {
      s +=this.origines[i];
      if(i<this.lg)
        s += " ";
    }
    s += " etc.\n";
    s +="Extrémités :\n";
    for(i=0;i<this.current;i++) {
      s +=this.origines[i]+(this.k-1)*this.raisons[i];
      if(i<this.lg)
        s += " ";
    }
    s += " etc.\n";
    document.f3.txt.value=s;
  }
  this.affiche=affiche;

  function cherche() {
    var a;
    this.set();
    do {
      a = this.suivant();
    } while(a == true);
    this.affiche();
  } 
  this.cherche=cherche;

}

function inf_calc() {
    var u = new infini();
    u.cherche();
}

function inf_clr() {  
  document.f3.txt.value=""
}

