在你前面有一个长长的阶梯,如果你每步跨2阶,那么最后剩1 阶;如果你每步跨3阶,那么最后剩2 阶;如果你每步跨5阶,那么最后剩4 阶;如果你每步跨6阶,那么最后剩5 阶;如果你每步跨7阶,那么正好走完,一阶不剩,问你这条阶梯最少有多少阶?

解决方案 »

  1.   

    procedure TForm1.Button2Click(Sender: TObject);
    var
      x:integer;
    begin
      x:=0;
      repeat
        x:=x+7;
      until ((x mod 2=1) and (x mod 3=2) and (x mod 5=4) and (x mod 6=5));
      showmessage(inttostr(x));end;
      

  2.   

    var
      n:Integer;
    begin
      n:=7;
      repeat
        n:=n+1;
      until ((n-1) mod 2=0) and ((n-2) mod 3=0) and ((n-4) mod 5=0) and ((n-5) mod 6=0) and (n mod 7=0);
      ShowMessage(IntToStr(n));
    end;结果是119