[Delphi (Object Pascal)] Pascal求出所有的既是回文数又是素数的三位数 →→→→→进入此内容的聊天室

来自 , 2020-07-28, 写在 Delphi (Object Pascal), 查看 173 次.
URL http://www.code666.cn/view/82273dfb
  1. var i:longint;
  2. function huiwen(n:longint):boolean;
  3. var a,b,c:longint;
  4. begin
  5. a:=n div 100;
  6. b:=n div 10 mod 10;
  7. c:=n mod 10;
  8. if n=100*c+10*b+a then huiwen:=true
  9. else huiwen:=false;
  10. end;
  11. function sushu(n:longint):boolean;
  12. var i:longint;
  13. begin
  14. sushu:=true;
  15. for i:=2 to trunc(sqrt(n)) do
  16. if n mod i=0 then sushu:=false;
  17. end;
  18. begin
  19. for i:=100 to 999 do
  20. if huiwen(i) and sushu(i) then write(i:5);
  21. end.
  22. //delphi/7231

回复 "Pascal求出所有的既是回文数又是素数的三位数"

这儿你可以回复上面这条便签

captcha