i am doing a project for my sis in unversity, and it says that i have to find the first 100 prime numbers and store them in an array.
i managed to find the prime numbers but when i try to store it in an array a bunch of other numbers come up, can you tell me what i am doing wrong? below is the code. pls help me.
then i have to change the prime numbers into either hex, octal, binary and decimal. i need help with this to.
Program Assignment; Uses crt; Var cOption: char; aPrime: array [1..541] of longint; iPrime,range: longint; cnt: integer; Procedure Prime; Var y,temp: longint; root: real; introot,count: longint; prime: boolean; Begin clrscr; cnt := 0; range := 541; for iPrime:= 2 to range do begin root:= int(sqrt(iPrime)); introot:=round(root); prime:= true; for y:=2 to introot do Begin if iPrime mod y = 0 then prime := false; End; if prime= true then Begin cnt := cnt + 1; write(iPrime,' '); aPrime[cnt] := iPrime; End; End; readln; End; Procedure ViewPrime; Begin clrscr; cnt := 0; Writeln('²²²²²² View Prime ²²²²²²'); Writeln; For iPrime:= 2 to range do Begin cnt := cnt + 1; write(aPrime[cnt],' '); End; Readln; End; BEGIN clrscr; Prime; END.