Numbers whose binary and ternary digit sums are prime: Difference between revisions

Added Easylang
No edit summary
(Added Easylang)
 
(5 intermediate revisions by 3 users not shown)
Line 755:
</pre>
 
 
=={{header|EasyLang}}==
<syntaxhighlight>
fastfunc isprim num .
if num < 2
return 0
.
i = 2
while i <= sqrt num
if num mod i = 0
return 0
.
i += 1
.
return 1
.
func digsum n b .
while n > 0
sum += n mod b
n = n div b
.
return sum
.
for i = 1 to 199
if isprim digsum i 2 = 1 and isprim digsum i 3 = 1
write i & " "
.
.
</syntaxhighlight>
{{out}}
<pre>
5 6 7 10 11 12 13 17 18 19 21 25 28 31 33 35 36 37 41 47 49 55 59 61 65 67 69 73 79 82 84 87 91 93 97 103 107 109 115 117 121 127 129 131 133 137 143 145 151 155 157 162 167 171 173 179 181 185 191 193 199
</pre>
 
=={{header|F_Sharp|F#}}==
Line 905 ⟶ 938:
=={{header|Fōrmulæ}}==
 
{{FormulaeEntry|page=https://formulae.org/?script=examples/Numbers_which_binary_and_ternary_digit_sum_are_prime}}
Fōrmulæ programs are not textual, visualization/edition of programs is done showing/manipulating structures but not text. Moreover, there can be multiple visual representations of the same program. Even though it is possible to have textual representation &mdash;i.e. XML, JSON&mdash; they are intended for storage and transfer purposes more than visualization and edition.
 
'''Solution'''
Programs in Fōrmulæ are created/edited online in its [https://formulae.org website], However they run on execution servers. By default remote servers are used, but they are limited in memory and processing power, since they are intended for demonstration and casual use. A local server can be downloaded and installed, it has no limitations (it runs in your own computer). Because of that, example programs can be fully visualized and edited, but some of them will not run if they require a moderate or heavy computation/memory resources, and no local server is being used.
 
[[File:Fōrmulæ - Numbers which binary and ternary digit sum are prime 01.png]]
In '''[https://formulae.org/?example=Numbers_which_binary_and_ternary_digit_sum_are_prime this]''' page you can see the program(s) related to this task and their results.
 
[[File:Fōrmulæ - Numbers which binary and ternary digit sum are prime 02.png]]
 
=={{header|Go}}==
Line 1,636 ⟶ 1,671:
157 162 167 171 173 179 181 185 191 193
199</pre>
 
=={{header|Quackery}}==
 
<code>digitsum</code> is defined at [[Sum digits of an integer#Quackery]].
 
<code>isprime</code> is defined at [[Primality by trial division#Quackery]].
 
<syntaxhighlight lang="Quackery"> []
200 times
[ i^ 3 digitsum isprime while
i^ 2 digitsum isprime while
i^ join ]
echo</syntaxhighlight>
 
{{out}}
 
<pre>[ 5 6 7 10 11 12 13 17 18 19 21 25 28 31 33 35 36 37 41 47 49 55 59 61 65 67 69 73 79 82 84 87 91 93 97 103 107 109 115 117 121 127 129 131 133 137 143 145 151 155 157 162 167 171 173 179 181 185 191 193 199 ]</pre>
 
=={{header|Raku}}==
Line 1,842 ⟶ 1,894:
{{libheader|Wren-math}}
{{libheader|Wren-fmt}}
<syntaxhighlight lang="wren">import "./math" for Int
{{libheader|Wren-seq}}
<syntaxhighlight lang="ecmascript">import "./mathfmt" for IntFmt
import "/fmt" for Fmt
import "/seq" for Lst
 
var numbers = []
Line 1,856 ⟶ 1,906:
}
System.print("Numbers < 200 whose binary and ternary digit sums are prime:")
Fmt.tprint("$4d", numbers, 14)
for (chunk in Lst.chunks(numbers, 14)) Fmt.print("$4d", chunk)
System.print("\nFound %(numbers.count) such numbers.")</syntaxhighlight>
 
2,069

edits