Prime or not?

FlamingClaw 0 Tallied Votes 291 Views Share

Prime or not?This little program will show prime numbers with green color from 0 to 100.By FlamingClaw;

Program Solution01;
Uses Crt;
Const Number = 100;
Var i:Word;{0..65535}

{checker function}
Function PrimeOrNot(pon00:word):String;
  Var
    pon01  :Word;
    Counter:Word;
  Begin
    Counter:=0;
    For pon01:=1 To pon00 Do
      Begin
        If (pon00 Mod pon01 = 0) Then
          Begin
            Counter:=Counter+1;
          End;{if}
      End;{for}
    If (Counter = 2) Then
      Begin
        TextColor(10);
        PrimeOrNot:=' Prime.';
      End
    Else Begin
          TextColor(15);
          PrimeOrNot:=' Not Prime.';
         End;{if}
  End;{function}

Begin {main}
   For i:=0 To Number Do
   WriteLn(i:3,PrimeOrNot(i));
   ReadLn;
End.

{
-= Note By FlamingClaw =-

All programs created by me  are written and tested
in Dev Pascal and/or Turbo Pascal 7.0

-= Created By FlamingClaw =-
-=2009.03.31=-
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.