Advertisement
WadeRollins2710

Untitled

Nov 27th, 2015
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 2.36 KB | None | 0 0
  1. Find the error, LOL :v
  2. Program Super_Prime;
  3. Uses crt;
  4. Var
  5.         i: LongInt;
  6.  
  7. Function Prime(n: Integer): Boolean;
  8.         Var
  9.                 A: Array [1..1000000] of Boolean;
  10.                 P: Array [1..4] of Word;
  11.                 i, j: Integer;
  12.         Begin
  13.                 Fillchar(A,sizeof(A),true);
  14.                 P[1]:=2; P[2]:=3; P[3]:=5; P[4]:=7;
  15.                 For i:=1 to 4 do
  16.                         For j:=2 to n div P[i] do
  17.                                 A[P[i]*j]:=false;
  18.                 If A[n]=true then Prime:=true
  19.                 else Prime:=false;
  20.         End;
  21.  
  22. Function SuperPrime(i: Integer): Boolean;
  23.         Var
  24.                 S: String;
  25.                 value, c: LongInt;
  26.         Begin
  27.                 SuperPrime:=false;
  28.                 Str(i,S);
  29.                 Val(S,value,c);
  30.                 If Prime(value) then {5}
  31.                         Begin
  32.                                 Delete(S,length(S),1);
  33.                                 Val(S,value,c);
  34.                                 If Prime(value) then {4}
  35.                                         Begin
  36.                                             Delete(S,length(S),1);
  37.                                             Val(S,value,c);
  38.                                             If Prime(value) then {3}
  39.                                                 Begin
  40.                                                         Delete(S,length(S),1);
  41.                                                         Val(S,value,c);
  42.                                                         If Prime(value) then {2}
  43.                                                                 Begin
  44.                                                                         Delete(S,length(S),1);
  45.                                                                         Val(S,value,c);
  46.                                                                         If Prime(value) then {1}
  47.                                                                             SuperPrime:=true;
  48.                                                                 End;
  49.                                                 End;
  50.                                         End;
  51.                         End;
  52.         End;
  53.  
  54. Procedure Output;
  55.         Begin
  56.                 For i:=10000 to 99999 do
  57.                         If SuperPrime(i)=true then
  58.                                 Writeln(i);
  59.                 Readln;
  60.         End;
  61.  
  62. Begin
  63.         Output;
  64. End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement