about summary refs log tree commit diff
path: root/others/volume1/004.pas
diff options
context:
space:
mode:
authorRaphael McSinyx <vn.mcsinyx@gmail.com>2017-02-12 16:18:20 +0700
committerRaphael McSinyx <vn.mcsinyx@gmail.com>2017-02-12 16:18:20 +0700
commit1a8e1e68759611a66ae116771da5f376c95a3b9f (patch)
treee663fa6adb9264046a876e552ff2a455215c3a8b /others/volume1/004.pas
parentdf9a0d140a7b7edef66f95aa13b5bb4488147f68 (diff)
downloadcp-1a8e1e68759611a66ae116771da5f376c95a3b9f.tar.gz
Update others/volume1
Diffstat (limited to 'others/volume1/004.pas')
-rw-r--r--others/volume1/004.pas18
1 files changed, 3 insertions, 15 deletions
diff --git a/others/volume1/004.pas b/others/volume1/004.pas
index caf5142..9ade431 100644
--- a/others/volume1/004.pas
+++ b/others/volume1/004.pas
@@ -1,7 +1,8 @@
+uses cmath;
+
 var
   prime: array [2..1000000] of boolean;
   i, j, n, k: longint;
-  b: boolean = true;
 
 begin
   for i := 2 to 1000000 do
@@ -12,20 +13,7 @@ begin
         prime[i * j] := false;
 
   readln(n, k);
-  if n < 2 then
-    writeln('FALSE')
-  else if n <= 1000000 then
-    writeln(prime[n])
-  else
-    begin
-      for i := 2 to trunc(sqrt(n)) do
-        if n mod i = 0 then
-        begin
-          b := false;
-          break
-        end;
-      writeln(b)
-    end;
+  writeln(isprime(n));
   for i := 2 to k do
     if prime[i] then
       write(i, ' ');