Darkrai1337

Untitled

Jan 10th, 2022 (edited)
1,129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.32 KB | None | 0 0
  1. program Project2;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. uses
  6.   SysUtils;
  7. var
  8.   n,p, i: integer;
  9.   BellNs : array[1..26] of Int64;
  10.   IsPrime : boolean;
  11. begin
  12.   i:= 0;
  13.  
  14.   BellNs[1] := 1;
  15.   BellNs[2] := 1;
  16.   BellNs[3] := 2;
  17.   BellNs[4] := 5;
  18.   BellNs[5] := 15;
  19.   BellNs[6] := 52;
  20.   BellNs[7] := 203;
  21.   BellNs[8] := 877;
  22.   BellNs[9] := 4140;
  23.   BellNs[10] := 21147;
  24.   BellNs[11] := 115975;
  25.   BellNs[12] := 678570;
  26.   BellNs[13] := 4213597;
  27.   BellNs[14] := 27644437;
  28.   BellNs[15] := 190899322;
  29.   BellNs[16] := 1382958545;
  30.   BellNs[17] := 10480142147;
  31.   BellNs[18] := 82864869804;
  32.   BellNs[19] := 682076806159;
  33.   BellNs[20] := 5832742205057;
  34.   BellNs[21] := 51724158235372;
  35.   BellNs[22] := 474869816156751;
  36.   BellNs[23] := 4506715738447323;
  37.   BellNs[24] := 44152005855084346;
  38.   BellNs[25] := 445958869294805289;
  39.   BellNs[26] := 4638590332229999353;
  40.  
  41.   for n:= 1 to 25 do
  42.     for p:= 2 to 25 do
  43.     begin
  44.       if (n + p <= 26) then
  45.       begin
  46.         IsPrime := true;
  47.         for i:= 2 to Trunc(sqrt(p)) do
  48.           if (p mod i) = 0 then
  49.           IsPrime := false;
  50.  
  51.         if IsPrime = true then
  52.         begin
  53.           if (BellNs[n+p] mod p) = ((BellNs[n] + BellNs[n+1]) mod p) then
  54.             Writeln('B(',n,'+',p,') = B(',n ,') + B(',n ,'+1)  (mod ',p,')');
  55.         end;
  56.       end;
  57.     end;
  58.  
  59.  
  60. readln;
  61. end.
Advertisement
Add Comment
Please, Sign In to add comment