Skip to content

Instantly share code, notes, and snippets.

@tuankiet65
Last active December 14, 2015 21:19
Show Gist options
  • Save tuankiet65/5150015 to your computer and use it in GitHub Desktop.
Save tuankiet65/5150015 to your computer and use it in GitHub Desktop.
Nhập vào một số nguyên dương n. tính tổng của các chữ số là số nguyên tố của n.
program bt2;
uses crt;
var n: int64;
tong, nchr: longint;
begin
clrscr;
write('Nhap n: ');
readln(n);
while n<>0 do begin
nchr:=n mod 10;
if nchr in [2, 3, 5, 7] then tong:=tong+nchr;
n:=n div 10;
end; x
write('Tong: ', tong);
readkey;
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment