aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--challenge-156/laurent-rosenfeld/julia/ch-1.jl16
-rw-r--r--challenge-156/laurent-rosenfeld/python/ch-1.py15
2 files changed, 31 insertions, 0 deletions
diff --git a/challenge-156/laurent-rosenfeld/julia/ch-1.jl b/challenge-156/laurent-rosenfeld/julia/ch-1.jl
new file mode 100644
index 0000000000..9522643082
--- /dev/null
+++ b/challenge-156/laurent-rosenfeld/julia/ch-1.jl
@@ -0,0 +1,16 @@
+primes = Dict(2 => 1, 3 => 1, 5 => 1, 7 => 1, 11 => 1, 13 => 1, 17 => 1, 19 => 1)
+count = 0
+for n in 2:20
+ n_bin = string(n, base=2)
+ num_1 = 0
+ for digit in n_bin
+ num_1 += parse(Int64, digit)
+ end
+ if num_1 ∈ keys(primes)
+ global count
+ count += 1
+ print(n, " ")
+ count >= 10 && break
+ end
+end
+println("")
diff --git a/challenge-156/laurent-rosenfeld/python/ch-1.py b/challenge-156/laurent-rosenfeld/python/ch-1.py
new file mode 100644
index 0000000000..34a923120c
--- /dev/null
+++ b/challenge-156/laurent-rosenfeld/python/ch-1.py
@@ -0,0 +1,15 @@
+primeset = {2, 3, 5, 7, 11, 13, 17, 19}
+count= 0
+for n in range(2, 20):
+ bin_n = format(n, 'b')
+ num_1 = 0
+ for x in bin_n:
+ if x == '1':
+ num_1 += 1
+
+ if num_1 in primeset:
+ count += 1
+ print(n, end =" ")
+ if count >= 10:
+ break
+print("")