ta gọi số ngược của 1 số là số tạo ra bằng cách viết các chữ số của số đã cho theo chiều từ trái qua phải (vd: số 123 có số ngược là 321). Một số nguyên x được gọi là số ngược của nó là những số nguyên tố cùng nhau (tức có ước số chung bằng 1). Ví dụ 123 là một số đối lập vì có ước số chung lớn nhất của 123 và 321 bằng 1. Hãy lập trình để xác định một số nguyên dương đã cho có phải là số đối lập hay không ?
Giúp mik với !!!
Hãy nhập câu hỏi của bạn vào đây, nếu là tài khoản VIP, bạn sẽ được ưu tiên trả lời.
uses crt; var a,b:array[1..100000]of integer; i,n,kt,j,dem,x,y,kt1:integer; st,st1:string; begin clrscr; write('Nhap n='); readln(n); for i:=1 to n do begin write('A[',i,']='); readln(a[i]); end; dem:=0; for i:=1 to n do if a[i]>1 then begin kt:=0; for j:=2 to a[i]-1 do if a[i] mod j=0 then begin kt:=1; break; end; if kt=0 then begin inc(dem); b[dem]:=a[i]; end; end; for i:=1 to dem do begin str(a[i],st); st1:=''; for j:=length(st) downto 1 do st1:=st1+st[j]; val(st1,x,y); kt1:=0; for j:=2 to x-1 do if x mod j=0 then begin kt1:=1; break; end; if kt1=0 then write(a[i]:4); end; readln; end.
uses crt; var a,b:array[1..100000]of integer; i,n,kt,j,dem,x,y,kt1:integer; st,st1:string; begin clrscr; write('Nhap n='); readln(n); for i:=1 to n do begin write('A[',i,']='); readln(a[i]); end; dem:=0; for i:=1 to n do if a[i]>1 then begin kt:=0; for j:=2 to a[i]-1 do if a[i] mod j=0 then begin kt:=1; break; end; if kt=0 then begin inc(dem); b[dem]:=a[i]; end; end; for i:=1 to dem do begin str(a[i],st); st1:=''; for j:=length(st) downto 1 do st1:=st1+st[j]; val(st1,x,y); kt1:=0; for j:=2 to x-1 do if x mod j=0 then begin kt1:=1; break; end; if kt1=0 then write(a[i]:4); end; readln; end.
Gọi số cần tìm là \(\overline{ab}\) theo đề bài
\(\overline{ba}-\overline{ab}=27\Rightarrow10b+a-10a-b=27\)
\(\Rightarrow9b-9a=27\Rightarrow b-a=3\) mà \(a+b=9\)
\(\Rightarrow b=6;a=3\)