Prosty program sprawdzajacy czy dana liczba jest autmorficzna -> (czy x znajduje się na koncu kwadrat x)
Jaką kolwiek liczbę bym nie wpisał zawsze pokazuje, że liczba jest automorficzna i nie mogę dojść dlaczego.
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
n,m,b,a:integer;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
m :=10;
a:=StrToInt(Edit1.Text);
b:=m;
while n>b
do b:=b*m;
a := (n*n) mod b;
if a<>n
then ShowMessage('Liczba nie jest automorficzna')
else ShowMessage('Liczba jest automorficzna');
end;
end.