Strange plus numbers: Difference between revisions
Content deleted Content added
(17 intermediate revisions by 11 users not shown) | |||
Line 13:
{{trans|Python}}
<
V xs = String(n).map(c -> Int(c))
R all(zip(xs, xs[1..]).map((a, b) -> a + b C (2, 3, 5, 7, 11, 13, 17)))
Line 23:
print(el, end' ‘ ’)
I L.index % 10 == 9
print()</
{{out}}
Line 42:
=={{header|Action!}}==
<
BYTE ARRAY primes=[0 0 1 1 0 1 0 1 0 0 0 1 0 1 0 0 0 1 0]
BYTE d,prev,first,sum
Line 77:
OD
PrintF("%E%EThere are %I strange plus numbers",count)
RETURN</
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Strange_plus_numbers.png Screenshot from Atari 8-bit computer]
Line 90:
=={{header|ALGOL 68}}==
Does not attempt to generalise beyond 3 digit numbers.
<
# the sum of the second 2 digits is prime #
# considers numbers n where 100 < n < 500 #
Line 105:
FI
OD
END</
{{out}}
<pre>
Line 119:
=={{header|ALGOL W}}==
{{Trans|ALGOL 68}}
<
% the sum of the second 2 digits is prime %
% considers numbers n where 100 < n < 500 %
Line 139:
end for_n
end.
</syntaxhighlight>
{{out}}
<pre>
Line 153:
=={{header|APL}}==
{{works with|Dyalog APL}}
<
{{out}}
Line 163:
=={{header|AppleScript}}==
<
-- isStrangePlus :: Int -> Bool
Line 362:
end tell
end if
end zipWith</
{{Out}}
<pre>'Strange Plus' numbers found in range [100..500]
Line 377:
389 411 412 414 416 430 432 434 438 470
474 476 492 494 498</pre>
=={{header|Arturo}}==
<syntaxhighlight lang="arturo">strangeNums: select 101..499 'x ->
and? -> prime? sum first.n:2 digits x
-> prime? sum last.n:2 digits x
loop split.every: 5 strangeNums 'x ->
print map x 's -> pad to :string s 3</syntaxhighlight>
{{out}}
<pre>111 112 114 116 120
121 123 125 129 141
143 147 149 161 165
167 202 203 205 207
211 212 214 216 230
232 234 238 250 252
256 258 292 294 298
302 303 305 307 320
321 323 325 329 341
343 347 349 383 385
389 411 412 414 416
430 432 434 438 470
474 476 492 494 498</pre>
=={{header|AWK}}==
<syntaxhighlight lang="awk">
# syntax: GAWK -f STRANGE_PLUS_NUMBERS.AWK
BEGIN {
Line 405 ⟶ 430:
return(1)
}
</syntaxhighlight>
{{out}}
<pre>
Line 419 ⟶ 444:
=={{header|BASIC}}==
<
20 FOR I=100 TO 500
30 N=I
Line 428 ⟶ 453:
80 R=N MOD 10
90 IF INSTR("CDFHLNR",CHR$(L+R+65)) THEN 50
100 NEXT I</
{{out}}
<pre> 111 112 114 116 120
Line 445 ⟶ 470:
=={{header|BCPL}}==
<
let smallprime(n) = n=2 | n=3 | n=5 | n=7 | n=11 | n=13 | n=17
Line 462 ⟶ 487:
$)
wrch('*N')
$) </
{{out}}
<pre>111 112 114 116 120 121 123 125 129 141
Line 473 ⟶ 498:
=={{header|BQN}}==
<
{{out}}
<pre>┌─
Line 486 ⟶ 511:
Generalized solution: a number is strange iff the sum of two consecutive digits is always prime. Numbers < 10 are considered non-strange.
<
static int p[19] = {0, 0, 1, 1, 0, 1, 0, 1, 0, 0,
Line 509 ⟶ 534:
}
return 0;
}</
{{out}}
Line 523 ⟶ 548:
=={{header|C++}}==
{{trans|Java}}
<
#include <vector>
Line 563 ⟶ 588:
test(101, 499);
return 0;
}</
{{out}}
<pre>111 112 114 116 120 121 123 125 129 141
Line 574 ⟶ 599:
=={{header|CLU}}==
<
small_primes = sequence[int]$[2,3,5,7,11,13,17]
for p: int in sequence[int]$elements(small_primes) do
Line 602 ⟶ 627:
end
end
end start_up</
{{out}}
<pre> 111 112 114 116 120 121 123 125 129 141
Line 613 ⟶ 638:
=={{header|COBOL}}==
<
PROGRAM-ID. STRANGE-PLUS-NUMBERS.
Line 651 ⟶ 676:
DISPLAY ROW,
MOVE SPACES TO ROW,
MOVE 1 TO PTR.</
{{out}}
<pre>111 112 114 116 120 121 123 125 129 141
Line 662 ⟶ 687:
=={{header|Comal}}==
<
0020 RETURN n#=2 OR (n# MOD 2<>0 AND n#<>1 AND n#<>9 AND n#<>15)
0030 ENDFUNC small'prime#
Line 687 ⟶ 712:
0240 ENDFOR i#
0250 PRINT
0260 END</
{{out}}
<pre>111 112 114 116 120 121 123 125 129 141
Line 698 ⟶ 723:
=={{header|Cowgol}}==
<
sub small_prime(n: uint8): (p: uint8) is
Line 731 ⟶ 756:
cand := cand + 1;
end loop;
print_nl();</
{{out}}
<pre>111 112 114 116 120 121 123 125 129 141
Line 742 ⟶ 767:
=={{header|Delphi}}==
{{Trans|Go}}
<syntaxhighlight lang="delphi">
program Strange_plus_numbers;
Line 787 ⟶ 811:
writeln(#10, count, ' strange plus numbers in all.');
readln;
end.</
=== Alternate solution ===
<syntaxhighlight lang="delphi">program StrangePlusNumbers;
const
m = 18;
var
pr: array [0..m] of Boolean;
n, k, a, b: Integer;
q: Boolean;
begin
// prime sieve
for n := 0 to m do
begin
q := n > 1;
for k := 2 to n - 1 do
if n mod k = 0 then q := False;
pr[n] := q
end;
k := 0;
for n := 101 to 499 do
begin
a := n div 10; // first two digits
b := n mod 100; // last two digits
if pr[a div 10 + a mod 10] and
pr[b div 10 + b mod 10] then
begin
Write(n);
Inc(k);
if k mod 10 = 0 then Writeln else Write(' ')
end
end
end.</syntaxhighlight>
{{out}}
<pre>111 112 114 116 120 121 123 125 129 141
143 147 149 161 165 167 202 203 205 207
211 212 214 216 230 232 234 238 250 252
256 258 292 294 298 302 303 305 307 320
321 323 325 329 341 343 347 349 383 385
389 411 412 414 416 430 432 434 438 470
474 476 492 494 498</pre>
=={{header|Draco}}==
<
word primes = 0x8A2B;
n>=2 and primes >> (n-2) & 1 = 1
Line 820 ⟶ 891:
fi
od
corp</
{{out}}
<pre> 111 112 114 116 120 121 123 125 129 141
Line 829 ⟶ 900:
389 411 412 414 416 430 432 434 438 470
474 476 492 494 498</pre>
=={{header|EasyLang}}==
<syntaxhighlight lang=text>
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 strange n .
while n >= 1000
n = n div 10
.
d1 = n mod 10
n = n div 10
d2 = n mod 10
n = n div 10
d3 = n mod 10
if isprim (d1 + d2) = 1 and isprim (d2 + d3) = 1
return 1
.
return 0
.
for i = 100 to 499
if strange i = 1
write i & " "
.
.
</syntaxhighlight>
{{out}}
<pre>
111 112 114 116 120 121 123 125 129 141 143 147 149 161 165 167 202 203 205 207 211 212 214 216 230 232 234 238 250 252 256 258 292 294 298 302 303 305 307 320 321 323 325 329 341 343 347 349 383 385 389 411 412 414 416 430 432 434 438 470 474 476 492 494 498
</pre>
=={{header|F_Sharp|F#}}==
This task uses [[Extensible_prime_generator#The_functions|Extensible Prime Generator (F#)]].<br>
<
// Strange numbers. Nigel Galloway: February 25th., 2021
let pD=[0..99]|>List.map(fun n->(n/10,n%10))|>List.filter(fun(n,g)->isPrime(n+g))
pD|>List.filter(fun(n,_)->n>0)|>List.map(fun(n,g)->(n,pD|>List.filter(fun(n,_)->n=g)))
|>List.collect(fun(n,g)->g|>List.map(fun(g,k)->n*100+g*10+k))|>List.filter((>)500)|>List.iter(printf "%d ");printfn ""
</syntaxhighlight>
{{out}}
<pre>
Line 845 ⟶ 956:
=={{header|Factor}}==
{{works with|Factor|0.99 2021-02-05}}
<
math.ranges math.text.utils prettyprint sequences ;
Line 855 ⟶ 966:
100 500 (a,b) [ strange+? ] filter dup
10 group [ [ pprint bl ] each nl ] each nl
length pprint " strange plus numbers found." print</
{{out}}
<pre>
Line 873 ⟶ 984:
=={{header|Forth}}==
{{trans|C}}
<
true , false , true , false , false , false , true ,
false , true , false , false , false , true , false ,
Line 905 ⟶ 1,016:
main
bye</
{{out}}
Line 921 ⟶ 1,032:
=={{header|FreeBASIC}}==
{{trans|AWK}}
<
Function isPrime(valor As Integer) As Boolean
If valor <= 1 Then Return False
Line 946 ⟶ 1,057:
Print !"\n\n"; k; " n£meros m s extra¤os encontrados."
Sleep
</syntaxhighlight>
{{out}}
<pre>
Line 964 ⟶ 1,075:
=={{header|Fōrmulæ}}==
{{FormulaeEntry|page=https://formulae.org/?script=examples/Strange_plus_numbers}}
'''Solution'''
[[File:Fōrmulæ - Strange plus numbers 01.png]]
[[File:Fōrmulæ - Strange plus numbers 02.png]]
[[File:Fōrmulæ - Strange plus numbers 03.png]]
=={{header|Go}}==
{{trans|Wren}}
<
import "fmt"
Line 1,003 ⟶ 1,118:
}
fmt.Printf("\n%d strange plus numbers in all.\n", count)
}</
{{out}}
Line 1,021 ⟶ 1,136:
=={{header|Haskell}}==
<
import Data.List.Split (chunksOf)
Line 1,045 ⟶ 1,160:
unlines
(unwords <$> chunksOf 10 (show <$> xs))
]</
{{Out}}
<pre>"Strange Plus" numbers found in range [100..500]
Line 1,060 ⟶ 1,175:
389 411 412 414 416 430 432 434 438 470
474 476 492 494 498</pre>
=={{header|J}}==
Definitions:
<syntaxhighlight lang="j">digits=: 10&#.inv"0
strangeplus=: 100&< * 500&> * (2&{. * ::0:&(1&p:)&(+/) _2&{.)@digits</syntaxhighlight>
Example:
<syntaxhighlight lang="j"> I.strangeplus i.500
111 112 114 116 120 121 123 125 129 141 143 147 149 161 165 167 202 203 205 207 211 212 214 216 230 232 234 238 250 252 256 258 292 294 298 302 303 305 307 320 321 323 325 329 341 343 347 349 383 385 389 411 412 414 416 430 432 434 438 470 474 476 492 494 498</syntaxhighlight>
=={{header|Java}}==
<
private static final boolean[] p = {
false, false, true, true, false,
Line 1,090 ⟶ 1,216:
}
}
}</
<syntaxhighlight lang="text">java Strange 101 499</
{{out}}
Line 1,109 ⟶ 1,235:
See e.g. [[Erd%C5%91s-primes#jq]] for a suitable implementation of `is_prime`.
<
def n: if length <= $n then . else .[0:$n] , (.[$n:] | n) end;
n;
Line 1,124 ⟶ 1,250:
| join(" ");
task</
{{out}}
<pre>
Line 1,138 ⟶ 1,264:
=={{header|Julia}}==
<
smallprimes = [2, 3, 5, 7, 11, 13, 17] # 0 <= all of these primes <= 18
paired_digit_sums(n) = (d = digits(n); [sum(p) for p in zip(d[1:end-1], d[2:end])])
Line 1,148 ⟶ 1,274:
end
end
</
<pre>
111 112 114 116 120 121 123 125 129 141 143 147 149
Line 1,159 ⟶ 1,285:
=={{header|Kotlin}}==
{{trans|Java}}
<
false, false, true, true, false,
true, false, true, false, false,
Line 1,198 ⟶ 1,324:
fun main() {
test(101, 499)
}</
{{out}}
<pre>111 112 114 116 120 121 123 125 129 141
Line 1,209 ⟶ 1,335:
=={{header|MAD}}==
<
INTERNAL FUNCTION(X)
Line 1,235 ⟶ 1,361:
TEST WHENEVER STGPLS.(I), PRINT RESULTS I
END OF PROGRAM</
{{out}}
<pre style='height:50ex;'>I = 111
Line 1,303 ⟶ 1,429:
I = 498</pre>
=={{header|Maple}}==
<
{{out}}
Line 1,315 ⟶ 1,441:
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<
Length[%]</
{{out}}
<pre>{111, 112, 114, 116, 120, 121, 123, 125, 129, 141, 143, 147, 149, 161, 165, 167, 202, 203, 205, 207, 211, 212, 214, 216, 230, 232, 234, 238, 250, 252, 256, 258, 292, 294, 298, 302, 303, 305, 307, 320, 321, 323, 325, 329, 341, 343, 347, 349, 383, 385, 389, 411, 412, 414, 416, 430, 432, 434, 438, 470, 474, 476, 492, 494, 498}
Line 1,322 ⟶ 1,448:
=={{header|Modula-2}}==
<
FROM InOut IMPORT WriteCard, WriteLn;
Line 1,355 ⟶ 1,481:
END;
WriteLn;
END StrangePlusNumbers.</
{{out}}
<pre> 111 112 114 116 120 121 123 125 129 141
Line 1,366 ⟶ 1,492:
=={{header|Nim}}==
<
proc digits(n: 100..999): array[3, int] =
Line 1,376 ⟶ 1,502:
if d[0] + d[1] in Primes and d[1] + d[2] in Primes:
inc count
stdout.write n, if count mod 13 == 0: '\n' else: ' '</
{{out}}
Line 1,387 ⟶ 1,513:
=={{header|Perl}}==
{{libheader|ntheory}}
<
use warnings;
use feature 'say';
Line 1,395 ⟶ 1,521:
my $n = my @SP = grep { my @d = split ''; is_prime $d[0]+$d[1] and is_prime $d[1]+$d[2] } $low+1 .. $high-1;
say "Between $low and $high there are $n strange-plus numbers:\n" .
(sprintf "@{['%4d' x $n]}", @SP[0..$n-1]) =~ s/(.{80})/$1\n/gr;</
{{out}}
<pre>Between 100 and 500 there are 65 strange-plus numbers:
Line 1,405 ⟶ 1,531:
=={{header|Phix}}==
Using the same approach as [[Strange_numbers#Phix]], so this should similarly scale/count easily to the 28-digit range.
<!--<
<span style="color: #008080;">constant</span> <span style="color: #000000;">poss</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">apply</span><span style="color: #0000FF;">(</span><span style="color: #004600;">true</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">sq_sub</span><span style="color: #0000FF;">,{{</span><span style="color: #7060A8;">get_primes</span><span style="color: #0000FF;">(-</span><span style="color: #000000;">7</span><span style="color: #0000FF;">)},</span><span style="color: #7060A8;">tagset</span><span style="color: #0000FF;">(</span><span style="color: #000000;">9</span><span style="color: #0000FF;">,</span><span style="color: #000000;">0</span><span style="color: #0000FF;">)}),</span>
<span style="color: #000000;">nxts</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">apply</span><span style="color: #0000FF;">(</span><span style="color: #004600;">true</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">filter</span><span style="color: #0000FF;">,{</span><span style="color: #000000;">poss</span><span style="color: #0000FF;">,{</span><span style="color: #008000;">"in"</span><span style="color: #0000FF;">},{{</span><span style="color: #000000;">0</span><span style="color: #0000FF;">,</span><span style="color: #000000;">9</span><span style="color: #0000FF;">}},{</span><span style="color: #008000;">"[]"</span><span style="color: #0000FF;">}})</span>
Line 1,424 ⟶ 1,550:
<span style="color: #004080;">sequence</span> <span style="color: #000000;">res</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">strange_plus</span><span style="color: #0000FF;">(</span><span style="color: #000000;">3</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">tagset</span><span style="color: #0000FF;">(</span><span style="color: #000000;">4</span><span style="color: #0000FF;">))</span> <span style="color: #000080;font-style:italic;">-- (3 digit numbers beginning 1..4)</span>
<span style="color: #7060A8;">printf</span><span style="color: #0000FF;">(</span><span style="color: #000000;">1</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"%d strange_plus numbers found: %s\n"</span><span style="color: #0000FF;">,{</span><span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">res</span><span style="color: #0000FF;">),</span><span style="color: #7060A8;">join</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">shorten</span><span style="color: #0000FF;">(</span><span style="color: #000000;">res</span><span style="color: #0000FF;">,</span><span style="color: #008000;">""</span><span style="color: #0000FF;">,</span><span style="color: #000000;">5</span><span style="color: #0000FF;">),</span><span style="color: #008000;">","</span><span style="color: #0000FF;">)})</span>
<!--</
{{out}}
<pre>
Line 1,431 ⟶ 1,557:
=={{header|Picat}}==
<
L = [N : N in 100..500, S = N.to_string.map(to_int),
prime(S[1]+S[2]),
Line 1,440 ⟶ 1,566:
end,
nl,
println(len=Len)</
{{out}}
Line 1,454 ⟶ 1,580:
=={{header|PL/I}}==
<
smallPrime: procedure(n) returns(bit);
declare n fixed;
Line 1,479 ⟶ 1,605:
end;
end;
end StrangePlusNumbers;</
{{out}}
<pre> 111 112 114 116 120 121 123 125 129 141
Line 1,490 ⟶ 1,616:
=={{header|PL/M}}==
<
BDOS: PROCEDURE(F,A); DECLARE F BYTE, A ADDRESS; GO TO 5; END BDOS;
EXIT: PROCEDURE; GO TO 0; END EXIT;
Line 1,541 ⟶ 1,667:
END;
CALL EXIT;
EOF</
{{out}}
<pre>111 112 114 116 120 121 123 125 129 141
Line 1,554 ⟶ 1,680:
Using [https://docs.sympy.org/latest/modules/ntheory.html sympy.isprime]
<
Type "help", "copyright", "credits" or "license()" for more information.
>>> from sympy import isprime
Line 1,562 ⟶ 1,688:
isprime(sum(int(c) for c in str(x)[1:]))]
[111, 112, 114, 116, 120, 121, 123, 125, 129, 141, 143, 147, 149, 161, 165, 167, 202, 203, 205, 207, 211, 212, 214, 216, 230, 232, 234, 238, 250, 252, 256, 258, 292, 294, 298, 302, 303, 305, 307, 320, 321, 323, 325, 329, 341, 343, 347, 349, 383, 385, 389, 411, 412, 414, 416, 430, 432, 434, 438, 470, 474, 476, 492, 494, 498]
>>> </
Or, as we may not need to wake up '''sympy''' just to check membership of {2, 3, 5, 7, 11, 13, 17}:
<
Line 1,625 ⟶ 1,751:
# MAIN ---
if __name__ == '__main__':
main()</
{{Out}}
<pre>"Strange Plus" numbers in range [100..500]
Line 1,638 ⟶ 1,764:
389 411 412 414 416 430 432 434 438 470
474 476 492 494 498</pre>
=={{header|Quackery}}==
<syntaxhighlight lang="Quackery"> [ ' [ 2 3 5 7 11 13 17 ]
find 7 < ] is prime ( n --> b )
[ 10 /mod
swap 10 /mod
tuck + prime not iff
[ 2drop false ] done
+ prime ] is strange+ ( n --> b )
[] 399 times
[ i^ 101 +
dup strange+ iff
join else drop ]
dup size echo
say " strange plus numbers:"
cr cr
witheach
[ echo
i^ 10 mod 9 = iff cr else sp ]</syntaxhighlight>
{{out}}
<pre>65 strange plus numbers:
111 112 114 116 120 121 123 125 129 141
143 147 149 161 165 167 202 203 205 207
211 212 214 216 230 232 234 238 250 252
256 258 292 294 298 302 303 305 307 320
321 323 325 329 341 343 347 349 383 385
389 411 412 414 416 430 432 434 438 470
474 476 492 494 498
</pre>
=={{header|R}}==
<syntaxhighlight lang="rsplus"># Primes up to 18
pr <- sapply(1:18, \(n) n > 1 && all(n %% seq(2, length.out = n - 2) > 0))
is.strange <- function(n) {
a <- as.integer(strsplit(as.character(n), "")[[1]])
pr[a[[1]] + a[[2]] + 1] && pr[a[[2]] + a[[3]] + 1]
}
a <- 101:499
a[sapply(a, is.strange)]</syntaxhighlight>
{{out}}
<pre> [1] 111 112 114 116 120 121 123 125 129 141 143 147 149 161 165 167 202 203 205 207 211 212 214
[24] 216 230 232 234 238 250 252 256 258 292 294 298 302 303 305 307 320 321 323 325 329 341 343
[47] 347 349 383 385 389 411 412 414 416 430 432 434 438 470 474 476 492 494 498</pre>
=={{header|Raku}}==
<syntaxhighlight lang="raku"
put +$_, " matching numbers from $start to $end:\n", $_ given
($start .. $end).hyper(:256batch,:8degree).grep: { all .comb.rotor(2 => -1).map: { .sum.is-prime } };</
{{out}}
<pre>65 matching numbers from 100 to 500:
Line 1,648 ⟶ 1,828:
=={{header|REXX}}==
<
parse arg LO HI . /*obtain optional arguments from the CL*/
if LO=='' | LO=="," then LO= 101 /*Not specified? Then use the default.*/
Line 1,670 ⟶ 1,850:
say # ' strange plus numbers found between ' LO " and " HI ' (inclusive)'
say
say strip($)</
{{out|output|text= when using the default inputs:}}
<pre>
Line 1,682 ⟶ 1,862:
=={{header|Ring}}==
<
load "stdlib.ring"
Line 1,708 ⟶ 1,888:
ok
next
</syntaxhighlight>
{{out}}
<pre>
Line 1,719 ⟶ 1,899:
389 411 412 414 416 430 432 434 438 470
474 476 492 494 498
</pre>
=={{header|RPL}}==
{{works with|HP|49}}
≪ { }
<span style="color:red">101 499</span> '''FOR''' n
n <span style="color:red">10</span> IDIV2 SWAP <span style="color:red">10</span> IDIV2
'''IF''' ROT OVER + ISPRIME? UNROT + ISPRIME? AND '''THEN''' n + '''END'''
'''NEXT'''
≫ '<span style="color:blue">TASK</span>' STO
{{out}}
<pre>
1: {111 112 114 116 120 121 123 125 129 141 143 147 149 161 165 167 202 203 205 207 211 212 214 216 230 232 234 238 250 252 256 258 292 294 298 302 303 305 307 320 321 323 325 329 341 343 347 349 383 385 389 411 412 414 416 430 432 434 438 470 474 476 492 494 498}
</pre>
=={{header|Ruby}}==
{{trans|Kotlin}}
<
false, false, true, true, false,
true, false, true, false, false,
Line 1,760 ⟶ 1,953:
end
test(101, 499)</
{{out}}
<pre>111 112 114 116 120 121 123 125 129 141
Line 1,771 ⟶ 1,964:
=={{header|Seed7}}==
<
const func boolean: prime (in integer: number) is
Line 1,802 ⟶ 1,995:
end if;
end for;
end func;</
{{out}}
<pre>
Line 1,811 ⟶ 2,004:
412 414 416 430 432 434 438 470 474 476 492 494 498
</pre>
=={{header|SETL}}==
<syntaxhighlight lang="setl">program strange_plus_numbers;
$ a sum of two digits is never >18
primes := {2, 3, 5, 7, 11, 13, 17};
strangeplus := {
n : n in [101..499]
| lowpairsum(n) in primes and highpairsum(n) in primes
};
loop for n in strangeplus do
putchar(lpad(str n, 5));
if (i +:= 1) mod 10 = 0 then print; end if;
end loop;
print;
proc lowpairsum(n);
return n mod 100 div 10 + n mod 10;
end proc;
proc highpairsum(n);
return lowpairsum(n div 10);
end proc;
end program;</syntaxhighlight>
{{out}}
<pre> 111 112 114 116 120 121 123 125 129 141
143 147 149 161 165 167 202 203 205 207
211 212 214 216 230 232 234 238 250 252
256 258 292 294 298 302 303 305 307 320
321 323 325 329 341 343 347 349 383 385
389 411 412 414 416 430 432 434 438 470
474 476 492 494 498</pre>
=={{header|Sidef}}==
<
is_prime(d[-1]+d[-2]) && is_prime(d[-2]+d[-3])
}.map{ .digits2num }.slices(10).each { .join(' ').say }</
{{out}}
<pre>
Line 1,827 ⟶ 2,053:
</pre>
=={{header|V (Vlang)}}==
{{trans|Go}}
<syntaxhighlight lang="v (vlang)">fn is_prime(n int) bool {
return n == 2 || n == 3 || n == 5 || n == 7 || n == 11 || n == 13 || n == 17
}
Line 1,856 ⟶ 2,082:
}
println("\n$count strange plus numbers in all.")
}</
{{out}}
Line 1,874 ⟶ 2,100:
=={{header|VTL-2}}==
<
20 N=101
30 K=N
Line 1,893 ⟶ 2,119:
180 #=C/10*0+0<%*!
190 ?=""
200 #=!</
{{out}}
<pre>111 112 114 116 120 121 123 125 129 141
Line 1,905 ⟶ 2,131:
=={{header|Wren}}==
Simple brute force is adequate for this.
<
var count = 0
var d = []
Line 1,923 ⟶ 2,149:
}
if (count % 10 != 0) System.print()
System.print("\n%(count) strange plus numbers in all.")</
{{out}}
Line 1,944 ⟶ 2,170:
A 16-bit solution for NASM under DOS. Assemble with <code>nasm -fbin strange.asm -o strange.com</code>. The prime sieve up to 18 is hard-coded.
<syntaxhighlight lang="text"> org 100h
mov cx, 10 ; cl is used for division, ch to count numbers printed on a line
Line 1,991 ⟶ 2,217:
p db 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0
k equ $-p</
{{out}}
Line 2,004 ⟶ 2,230:
=={{header|XPL0}}==
<
int N, A, B, S;
[N:= N/10;
Line 2,023 ⟶ 2,249:
IntOut(0, N);
if rem(Cnt/20) = 0 then CrLf(0) else ChOut(0, ^ )];
]</
{{out}}
|