Jump to content

Chowla numbers: Difference between revisions

(→‎=={{header|Visual Basic}}==: added Visual Basic example)
Line 515:
</pre>
 
=={{header|J}}==
'''Solution:'''
<lang j>uniqFactors=: (}.@i.@# -.&0@~.@,@(*/\ , */\.) ])@q:
chowla=: +/@uniqFactors
 
intsbelow=: (2 }. i.)"0
countPrimesbelow=: +/@(0 = chowla)@intsbelow
findPerfectsbelow=: (#~ <: = chowla)@intsbelow</lang>
'''Tasks:'''
<lang j> (] ,. chowla) >: i. 37 NB. chowla numbers 1-37
1 0
2 0
3 0
4 2
5 0
6 5
7 0
8 6
9 3
10 7
11 0
12 15
13 0
14 9
15 8
16 14
17 0
18 20
19 0
20 21
21 10
22 13
23 0
24 35
25 5
26 15
27 12
28 27
29 0
30 41
31 0
32 30
33 14
34 19
35 12
36 54
37 0
countPrimesbelow 100 1000 10000 100000 1000000 10000000
25 168 1229 9592 78498
findPerfectsbelow 35000000
6 28 496 8128 33550336</lang>
=={{header|Julia}}==
<lang julia>using Primes, Formatting
892

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.