Pascal 8

S

syphuongcuong3

PHP:
USES crt;
VAR i,j,n,count:WORD;
    check:INTEGER;
BEGIN
    clrscr;
    write('Nhap n: ');readln(n);
    count:=0;i:=2;
    WHILE count<=n DO
        BEGIN
            check:=1;
            IF (i=2) OR (i=3) THEN
            BEGIN
                write(i,' ');
                count:=count+1;
            END
            ELSE
                BEGIN
                    FOR j:=2 TO trunc(sqrt(i)) DO
                         IF i MOD j=0 THEN check:=0;
                    IF check=1 THEN
                         BEGIN
                              write(i,' ');count:=count+1;
                         END;
                END;
            i:=i+1;
        END;
    readln;
END.
 
Top Bottom