rosettacode: pernicious numbers
authorBlackMinou <romain.chanoir@viacesi.fr>
Wed, 10 Jun 2015 07:39:56 +0000 (09:39 +0200)
committerBlackMinou <romain.chanoir@viacesi.fr>
Fri, 12 Jun 2015 07:22:57 +0000 (09:22 +0200)
Signed-off-by: BlackMinou <romain.chanoir@viacesi.fr>

examples/rosettacode/pernicious_numbers.nit [new file with mode: 0644]
tests/sav/pernicious_numbers.res [new file with mode: 0644]

diff --git a/examples/rosettacode/pernicious_numbers.nit b/examples/rosettacode/pernicious_numbers.nit
new file mode 100644 (file)
index 0000000..308779b
--- /dev/null
@@ -0,0 +1,22 @@
+#!/usr/bin/env nit
+#
+# This file is part of NIT ( http://www.nitlanguage.org ).
+# This program is public domain
+
+# Task: Pernicious numbers
+#
+# SEE: http://rosettacode.org/wiki/Pernicious_numbers
+
+var n_pernicious = 0
+var x = 0
+while n_pernicious < 25 do
+       if x.number_bits(1).is_prime then
+               print x
+               n_pernicious += 1
+       end
+       x += 1
+end
+
+for i in [888888877..888888888[ do
+       if i.number_bits(1).is_prime then print i
+end
diff --git a/tests/sav/pernicious_numbers.res b/tests/sav/pernicious_numbers.res
new file mode 100644 (file)
index 0000000..aa4ba41
--- /dev/null
@@ -0,0 +1,31 @@
+3
+5
+6
+7
+9
+10
+11
+12
+13
+14
+17
+18
+19
+20
+21
+22
+24
+25
+26
+28
+31
+33
+34
+35
+36
+888888877
+888888878
+888888880
+888888883
+888888885
+888888886