pascal inputs an integer A to determine whether it is prime or not.

Updated on technology 2024-02-29
10 answers
  1. Anonymous users2024-02-06

    Hey, poor bud!

    Ah, your brain is used to keep your neck out of the rain!

    Please be sure:

  2. Anonymous users2024-02-05

    Indeed, the 6th floor is silly and naïve.

  3. Anonymous users2024-02-04

    There are too many loops on the first floor, the program error on the second floor, i should be 1 to trunc(sqrt(a))+1 in the for loop, which may cause some numbers to fail to pass, the fourth floor is also, the fifth floor is also, when the decimal part of the value of sqrt(a) is less than the error, it will cause an error, the sixth floor is completely wrong, i is an integer variable, sqrt(n) is a real type, basically can not be compiled.

    var i,a:longint;

    beginreadln(a);

    for i:=2 to trunc(sqrt(a))+1 doif a mod i=0 then

    beginwriteln('no,it is not a primr.');

    halt;end; writeln('yes, it is a primr.')

    end.

  4. Anonymous users2024-02-03

    Obviously, a prime number is a number that is not divisible by a number other than 1 and itself.

    for i:=2 to trunc(sqrt(n)) doif n mod i=0 then exit(false);

    exit(true);

    The landlord can think for himself why sqrt is fine.

  5. Anonymous users2024-02-02

    Once, you'll know

    A lot of · These language questions

  6. Anonymous users2024-02-01

    What's upstairs? Why do you still have multiple loops? Find all prime numbers that don't exceed a? Finding prime numbers only requires a cycle, which is the basic algorithm of pascal, and must be mastered!

    program zhishu;

    var a,f,n:longint;

    beginf:=0;

    readln(a);

    for n:=2 to trunc(sqrt(a)) doif a mod n=0 then

    begin f:=1;break;end;

    if f=1 then writeln ('false') else writeln('true');

    end.

  7. Anonymous users2024-01-31

    a ,i,b,c : real;

    There's a problem here.

    Real numbers cannot be used as variables for loops.

    It would be nice to change real to integer.

    I also made this mistake a lot when I was just starting out.

  8. Anonymous users2024-01-30

    var n,i:longint;b:boolean;

    beginreadln(n);

    if odd(n) then

    beginb:=false;i:=1;

    while (2<=trunc(sqrt(n)))and (b=false) do

    if (n mod (i+1)<>0) then b:=true;

    if b then writeln('yes') else writeln('no');

    end;end.

    Please refer to it. (Programming Beginners).

  9. Anonymous users2024-01-29

    with a subroutine.

    Specifically**I'll give it to you.

    I didn't test it. program abc;

    var i,k,m,n:longint;

    function isprime(n:longint):boolean;

    beginfunction:=true;

    for i:=2 to sqrt(n) doif n mod i=0 then

    beginfunction:=false;

    exit;end;

    end;begin

    readln(n);

    if isprime(n) then writeln('yes') else writeln('no');

    end.Seek the correct solution.

  10. Anonymous users2024-01-28

    var s:ansistring; a:integer;begin read(s); val(s[length(s)],a); if odd(a) then write('jishu') else write('oushu');end.

    The number of digits you lose does not exceed 2 billion.

Related questions
6 answers2024-02-29

Refer to the upstairs, but upstairs doesn't know then without adding a statement? >>>More

10 answers2024-02-29

In the sound of firecrackers, the spring breeze sends warmth into Tusu - Yuan Ri (Song) Wang Anshi. >>>More

9 answers2024-02-29

How to delete a page in Word?

10 answers2024-02-29

Don't capitalize it, no, it hurts to look at your head.

12 answers2024-02-29

With Sogou. Go ahead and give it a try.

Super Internet thesaurus, all-encompassing. >>>More