• 0
Sign in to follow this  
Guest --Neew --

Numeros Primos

Question

Guest --Neew --

aqui ta o meu codigo fiz em BCB.. mas n sei se esta correto essa linha de rascicinio.. ele funcionou perfeitamente.. poderiam me explicar se esta certo ou errado???

o simples falto de funcionar n quer dizer q esta certo..

obrigado

int n,i,x,d;

d=0;

n=atoi(Edit1->Text.c_str());

if(n<0)

{

ShowMessage("NOOB");

Edit1->SetFocus();

Edit1->Clear();

Edit2->Clear();

}

else

if (n==0 || n==1)

Edit2->Text=("não");

else

if (n==2 || n==3)

Edit2->Text=("SIM");

else

{

for (i=2;i<n;i++)

{

x=n%i;

if(x==0)

d=1;

}

if (d==1)

Edit2->Text=("não");

else

Edit2->Text=("SIM");

}

}

Share this post


Link to post
Share on other sites

3 answers to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this