Arithmetic numbers: Difference between revisions

added Arturo
(added Arturo)
Line 253:
There are 88219 composite arithmetic numbers up to 125587
</pre>
 
=={{header|Arturo}}==
<syntaxhighlight lang="arturo">arithmetic?: function [n][
avg: average factors n
zero? abs avg - to :integer avg
]
 
composite?: function [n]->
not? prime? n
 
arithmeticsUpTo: function [lim][
items: select.first: lim 1..∞ => arithmetic?
print [(to :string lim)++"th" "arithmetic number:" last items]
print ["Number of composite arithmetic numbers <= " last items ":" dec enumerate items => composite?]
print ""
]
 
first100: select.first:100 1..∞ => arithmetic?
 
loop split.every: 10 first100 'x ->
print map x 's -> pad to :string s 4
 
print ""
 
arithmeticsUpTo 1000
arithmeticsUpTo 10000
 
; stretch goal
arithmeticsUpTo 100000
arithmeticsUpTo 1000000</syntaxhighlight>
 
{{out}}
 
<pre> 1 3 5 6 7 11 13 14 15 17
19 20 21 22 23 27 29 30 31 33
35 37 38 39 41 42 43 44 45 46
47 49 51 53 54 55 56 57 59 60
61 62 65 66 67 68 69 70 71 73
77 78 79 83 85 86 87 89 91 92
93 94 95 96 97 99 101 102 103 105
107 109 110 111 113 114 115 116 118 119
123 125 126 127 129 131 132 133 134 135
137 138 139 140 141 142 143 145 147 149
 
1000th arithmetic number: 1361
Number of composite arithmetic numbers <= 1361 : 782
 
10000th arithmetic number: 12953
Number of composite arithmetic numbers <= 12953 : 8458
 
100000th arithmetic number: 125587
Number of composite arithmetic numbers <= 125587 : 88219
 
1000000th arithmetic number: 1228663
Number of composite arithmetic numbers <= 1228663 : 905043 </pre>
 
=={{header|AutoHotkey}}==
1,532

edits