Strange numbers: Difference between revisions

m
syntax highlighting fixup automation
(J)
m (syntax highlighting fixup automation)
Line 16:
{{trans|Python}}
 
<langsyntaxhighlight lang="11l">F is_strange(n)
V xs = String(n).map(c -> Int(c))
R all(zip(xs, xs[1..]).map((a, b) -> abs(a - b) C (2, 3, 5, 7)))
Line 26:
print(el, end' ‘ ’)
I L.index % 10 == 9
print()</langsyntaxhighlight>
 
{{out}}
Line 47:
 
=={{header|Action!}}==
<langsyntaxhighlight Actionlang="action!">BYTE Func IsStrangeNumber(INT i)
BYTE ARRAY primes=[0 0 1 1 0 1 0 1 0 0]
BYTE d,diff,prev
Line 81:
OD
PrintF("%E%EThere are %I strange numbers",count)
RETURN</langsyntaxhighlight>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Strange_numbers.png Screenshot from Atari 8-bit computer]
Line 94:
 
=={{header|Ada}}==
<langsyntaxhighlight Adalang="ada">with Ada.Text_IO; use Ada.Text_IO;
 
procedure Strange_Numbers is
Line 134:
end loop;
Put_Line ("Strange numbers in range 1_000_000_000 .. 1_999_999_999: " & Count'Image);
end Strange_Numbers;</langsyntaxhighlight>
{{out}}
<pre>
Line 152:
 
=={{header|ALGOL W}}==
<langsyntaxhighlight lang="algolw">begin % find "strange numbers" - numbers where digits differ from the next %
% by a prime %
% returns true if n is strange, false otherwise %
Line 190:
end for_n
end
end.</langsyntaxhighlight>
{{out}}
<pre>
Line 201:
 
=={{header|APL}}==
<langsyntaxhighlight APLlang="apl">(⊢(/⍨)(∧/2 3 5 7∊⍨2+/⍎¨∘⍕)¨) 100+⍳400</langsyntaxhighlight>
{{out}}
<pre>111 112 114 116 120 121 123 125 141 143 161 202 203 205 207 211 212 214 216 230 232 234 250 252 302 303 305 307 320 321
Line 207:
 
=={{header|AppleScript}}==
<langsyntaxhighlight AppleScriptlang="applescript">--------------------- STRANGE NUMBERS --------------------
 
-- isStrange :: Int -> Bool
Line 418:
end tell
end if
end zipWith</langsyntaxhighlight>
{{Out}}
<pre>Strange numbers found in range [100..500]
Line 437:
 
=={{header|AWK}}==
<syntaxhighlight lang="awk">
<lang AWK>
# syntax: GAWK -f STRANGE_NUMBERS.AWK
BEGIN {
Line 469:
}
function abs(x) { if (x >= 0) { return x } else { return -x } }
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 485:
 
=={{header|BASIC}}==
<langsyntaxhighlight lang="basic">10 DEFINT I,J,K: DEFSTR S
20 FOR I=100 TO 500
30 S=STR$(I)
Line 493:
70 NEXT J
80 PRINT I,
90 NEXT I</langsyntaxhighlight>
{{out}}
<pre> 130 131 135 136 138
Line 514:
496 497</pre>
=={{header|BCPL}}==
<langsyntaxhighlight lang="bcpl">get "libhdr"
 
let dgtprime(x) = x=2 | x=3 | x=5 | x=7
Line 530:
$)
wrch('*N')
$)</langsyntaxhighlight>
{{out}}
<pre> 130 131 135 136 138 141 142 146 147 149
Line 543:
 
=={{header|BQN}}==
<langsyntaxhighlight lang="bqn">↑‿10⥊((∧´(|¯1↓«-⊢)∊⟨2,3,5,7⟩˙)○•Fmt)¨⊸/100+↕400</langsyntaxhighlight>
{{out}}
The unused positions in the table are filled with <code>0</code>s, because that's the behaviour
Line 562:
=={{header|C}}==
{{trans|Go}}
<langsyntaxhighlight lang="c">#include <stdbool.h>
#include <stdio.h>
 
Line 600:
 
return 0;
}</langsyntaxhighlight>
{{out}}
<pre>Strange numbers in the open interval (100, 500) are:
Line 616:
 
===Extended task===
<langsyntaxhighlight lang="c">#include <stdio.h>
 
const int next_digit[] = {
Line 655:
 
return 0;
}</langsyntaxhighlight>
{{out}}
<pre>% ./a.out | fmt
Line 669:
=={{header|C++}}==
{{trans|Java}}
<langsyntaxhighlight lang="cpp">#include <algorithm>
#include <iostream>
#include <vector>
Line 720:
 
return 0;
}</langsyntaxhighlight>
{{out}}
<pre>Strange numbers in range [100..500]
Line 736:
 
=={{header|CLU}}==
<langsyntaxhighlight lang="clu">digits = iter (n: int) yields (int)
while n>0 do
yield(n // 10)
Line 771:
end
end
end start_up</langsyntaxhighlight>
{{out}}
<pre>130 131 135 136 138 141 142 146 147 149
Line 784:
 
=={{header|COBOL}}==
<langsyntaxhighlight lang="cobol"> IDENTIFICATION DIVISION.
PROGRAM-ID. STRANGE-NUMBERS.
Line 819:
MOVE NUM TO N-OUT.
DISPLAY N-OUT.
DONE. EXIT.</langsyntaxhighlight>
{{out}}
<pre style='height:50ex;'>130
Line 910:
 
=={{header|Cowgol}}==
<langsyntaxhighlight lang="cowgol">include "cowgol.coh";
 
sub abs(n: int8): (r: uint8) is
Line 945:
n := n + 1;
end loop;
print_nl();</langsyntaxhighlight>
{{out}}
<pre>130 131 135 136 138 141 142 146 147 149
Line 958:
 
=={{header|Draco}}==
<langsyntaxhighlight lang="draco">proc nonrec strange(word n) bool:
bool is_strange;
short da, db, diff;
Line 986:
fi
od
corp</langsyntaxhighlight>
{{out}}
<pre>130 131 135 136 138 141 142 146 147 149
Line 999:
 
=={{header|F_Sharp|F#}}==
<langsyntaxhighlight lang="fsharp">
// Strange numbers. Nigel Galloway: February 25th., 2021
let N=Array.init 10(fun n->[2;3;5;7]|>List.collect(fun g->[n+g;n-g])|>List.filter((<) -1)|>List.filter((>)10))
[1..4]|>List.collect(fun g->N.[g]|>List.map(fun n->g*10+n%10))|>List.collect(fun n->N.[n%10]|>List.map(fun g->n*10+g%10))|>List.iter(printf "%d "); printfn ""
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,012:
===Identifying and filtering===
{{works with|Factor|0.99 2020-08-14}}
<langsyntaxhighlight lang="factor">USING: grouping io kernel math.ranges math.statistics
math.text.utils math.vectors prettyprint sequences ;
 
Line 1,022:
100 500 (a,b) [ strange? ] filter dup
10 group [ [ pprint bl ] each nl ] each nl
length pprint " strange numbers found." print</langsyntaxhighlight>
{{out}}
<pre>
Line 1,043:
Since we know the next possible digits based on the current last digit, we can construct strange numbers with a backtracking algorithm.
{{works with|Factor|0.99 2020-08-14}}
<langsyntaxhighlight lang="factor">USING: backtrack compiler.tree.propagation.call-effect
formatting io kernel sequences sequences.generalizations
tools.memory.private tools.time ;
Line 1,065:
dup length commas write
" 10-digit strange numbers beginning with 1:" print
[ first2 ] [ last2 ] bi "%u\n%u\n...\n%u\n%u\n" printf</langsyntaxhighlight>
{{out}}
<pre>
Line 1,079:
 
=={{header|FreeBASIC}}==
<langsyntaxhighlight lang="freebasic">function is_strange( n as ulongint ) as boolean
dim as uinteger d, ld, a
if n<10 then return true 'arbitrary, but makes the recursion easier
Line 1,098:
if is_strange(n) then c+=1
next n
print using "There are ####### 10-digit strange numbers beginning with 1.";c</langsyntaxhighlight>
{{out}}<pre>
Strange numbers between 100 and 500
Line 1,106:
 
=={{header|Forth}}==
<langsyntaxhighlight lang="forth">\ tests whether n is prime for 0 <= n < 10
: prime? ( n -- ? )
1 swap lshift 0xac and 0<> ;
Line 1,136:
 
main
bye</langsyntaxhighlight>
 
{{out}}
Line 1,154:
===Basic task===
{{trans|Wren}}
<langsyntaxhighlight lang="go">package main
 
import "fmt"
Line 1,188:
}
fmt.Printf("\n%d strange numbers in all.\n", count)
}</langsyntaxhighlight>
 
{{out}}
Line 1,209:
===Stretch goal===
{{trans|Julia}}
<langsyntaxhighlight lang="go">package main
 
import "fmt"
Line 1,239:
}
fmt.Println("Found", len(strangeOnes), places, "\b-digit strange numbers beginning with", start)
}</langsyntaxhighlight>
 
{{out}}
Line 1,247:
 
=={{header|Haskell}}==
<langsyntaxhighlight lang="haskell">import Data.List (intercalate)
import Data.List.Split (chunksOf)
 
Line 1,270:
unlines
(unwords <$> chunksOf 10 (show <$> xs))
]</langsyntaxhighlight>
{{Out}}
<pre>Strange numbers found in range [100..500]
Line 1,290:
=={{header|J}}==
 
<langsyntaxhighlight Jlang="j">isStrange=: ([: */ 2 3 5 7 e.&:|~ 2 -/\ 10 #.inv ])"0
 
strangePair=: (1 p: ::0:"0 i.10),. 0 1}.isStrange (+ 10&*)"0/~ i.10</langsyntaxhighlight>
 
To test if a number is strange, we check if the absolute value of the differences of adjacent pairs of digits are 2, 3, 5 or 7.
Line 1,300:
Task examples:
 
<langsyntaxhighlight Jlang="j"> (#~ 100&<:) I. isStrange i.500
130 131 135 136 138 141 142 146 147 149 161 163 164 168 169 181 183 185 186 202 203 205 207 241 242 246 247 249 250 252 253 257 258 270 272 274 275 279 292 294 296 297 302 303 305 307 313 314 316 318 350 352 353 357 358 361 363 364 368 369 381 383 385 386 ...
#{{ ;<@{{x,"1 0 I. ({:x){y }}&strangePair"1 y}}^:9 ,:1
853423</langsyntaxhighlight>
 
=={{header|Java}}==
{{trans|Python}}
<langsyntaxhighlight Javalang="java">import java.util.LinkedList;
import java.util.List;
import java.util.function.BiPredicate;
Line 1,359:
}
}
}</langsyntaxhighlight>
{{out}}
<pre>Strange numbers in range [100..500]
Line 1,379:
 
===Filter method===
<syntaxhighlight lang="jq">
<lang jq>
def is_strange:
def digits: tostring | explode | map([.] | implode | tonumber);
Line 1,401:
 
task(100; 500; is_strange)
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 1,420:
===Generator method===
`lpad` and and `nwise` are as above and so their definitions are not repeated.
<syntaxhighlight lang="jq">
<lang jq>
# input: width
# $start: maximum first digit allowed e.g. 9 for unrestricted
Line 1,442:
[3 | generate(4) | map(tostring) | join("") | tonumber]
| nwise(10) | map(lpad(3)) | join(" ")
</syntaxhighlight>
</lang>
{{out}}
As above, except for the header.
===Stretch goal===
Using generate/1 as already defined:
<syntaxhighlight lang="jq">
<lang jq>
def count(s): reduce s as $x (null; .+1);
count(10 | generate(1))
</langsyntaxhighlight>
 
{{out}}
Line 1,459:
=={{header|Julia}}==
===Filter method===
<langsyntaxhighlight lang="julia">isstrange(n::Integer) = (d = digits(n); all(i -> abs(d[i] - d[i + 1]) ∈ [2, 3, 5, 7], 1:length(d)-1))
 
function filter_open_interval(start, stop, f, doprint=true, rowlength=92)
Line 1,475:
 
filter_open_interval(100, 500, isstrange)
</langsyntaxhighlight>{{out}}
<pre>
Finding numbers matching isstrange for open interval (100, 500):
Line 1,488:
===Generator method===
HT: Factor for the table.
<langsyntaxhighlight lang="julia">function countstrange(places, fixedstart=1)
possibles = [
[2, 3, 5, 7],
Line 1,514:
countstrange(10)
@time countstrange(10)
</langsyntaxhighlight>{{out}}
<pre>
Found 853423 10-digit strange numbers with the most significant digit 1.
Line 1,524:
=={{header|Kotlin}}==
{{trans|Java}}
<langsyntaxhighlight lang="scala">import kotlin.math.abs
 
fun digits(n: Int): List<Int> {
Line 1,568:
}
println()
}</langsyntaxhighlight>
{{out}}
<pre>Strange numbers in range [100..500]
Line 1,584:
 
=={{header|MAD}}==
<langsyntaxhighlight MADlang="mad"> NORMAL MODE IS INTEGER
INTERNAL FUNCTION(D)
Line 1,617:
 
VECTOR VALUES F = $I4*$
END OF PROGRAM </langsyntaxhighlight>
{{out}}
<pre style='height:50ex;'>STRANGE NUMBERS
Line 1,709:
 
=={{header|Mathematica}}/{{header|Wolfram Language}}==
<syntaxhighlight lang="mathematica">
<lang Mathematica>
Select[Range[101, 499],
AllTrue[Partition[IntegerDigits[#], 2, 1], Differences /* First /* PrimeQ] &
]</langsyntaxhighlight>
{{out}}
<pre>{130,131,135,136,138,141,142,146,147,149,161,163,164,168,169,181,183,185,186,202,203,205,207,241,242,246,247,249,250,252,253,257,258,270,272,274,275,279,292,294,296,297,302,303,305,307,313,314,316,318,350,352,353,357,358,361,363,364,368,369,381,383,385,386,413,414,416,418,420,424,425,427,429,461,463,464,468,469,470,472,474,475,479,492,494,496,497}</pre>
 
=={{header|Modula-2}}==
<langsyntaxhighlight lang="modula2">MODULE StrangeNumbers;
FROM InOut IMPORT WriteCard, WriteLn;
 
Line 1,750:
END;
WriteLn
END StrangeNumbers.</langsyntaxhighlight>
{{out}}
<pre> 130 131 135 136 138 141 142 146 147 149
Line 1,765:
Our program finds the strange numbers with a given number of digits. Filtering is done afterwards. It consumes a lot of memory but is able to find the result in less than a second on our small laptop.
 
<langsyntaxhighlight Nimlang="nim">import algorithm, sequtils
 
const PrimeDigits = [2, 3, 5, 7]
Line 1,802:
 
result = findStrangeNumbers(10).filterIt(it div 1_000_000_000 == 1)
echo "\nFound ", result.len, " strange numbers with 10 digits and starting with 1."</langsyntaxhighlight>
 
{{out}}
Line 1,819:
Not dynamically memorizing of all numbers saves much time 200ms -> 4ms.<BR>
Count is about 4.6 to the power of Digitscount -> first digit 1 followed by 9 digit -> 4.6^9 = 922190
<langsyntaxhighlight lang="pascal">program strangenumbers;
 
const
Line 1,905:
Writeln;
Writeln('Count : ',cnt);
end.</langsyntaxhighlight>
{{out}}
<pre>
Line 1,923:
 
=={{header|Perl}}==
<langsyntaxhighlight lang="perl">use strict;
use warnings;
use feature 'say';
Line 1,937:
my $cnt = my @strange = grep { is_strange($_) } $low+1 .. $high-1;
say "Between $low and $high there are $cnt strange numbers:\n" .
(sprintf "@{['%5d' x $cnt]}", @strange[0..$cnt-1]) =~ s/(.{80})/$1\n/gr;</langsyntaxhighlight>
{{out}}
<pre>Between 100 and 500 there are 87 strange numbers:
Line 1,948:
 
=={{header|Phix}}==
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<span style="color: #008080;">constant</span> <span style="color: #000000;">diff</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{-</span><span style="color: #000000;">7</span><span style="color: #0000FF;">,-</span><span style="color: #000000;">5</span><span style="color: #0000FF;">,-</span><span style="color: #000000;">3</span><span style="color: #0000FF;">,-</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #000000;">3</span><span style="color: #0000FF;">,</span><span style="color: #000000;">5</span><span style="color: #0000FF;">,</span><span style="color: #000000;">7</span><span style="color: #0000FF;">},</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_add</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;">diff</span><span style="color: #0000FF;">}}),</span>
Line 1,970:
<span style="color: #004080;">sequence</span> <span style="color: #000000;">res</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">strange</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 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>
<!--</langsyntaxhighlight>-->
{{out}}
<pre>
Line 1,977:
=== stretch goal ===
Dunno when to quit, me. As there does not appear to be much interest in which 1-digits are strange, I've shown three ways to set ones (output of 0, 10, or 4).
<!--<langsyntaxhighlight Phixlang="phix">(phixonline)-->
<span style="color: #008080;">constant</span> <span style="color: #000000;">diff</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{-</span><span style="color: #000000;">7</span><span style="color: #0000FF;">,-</span><span style="color: #000000;">5</span><span style="color: #0000FF;">,-</span><span style="color: #000000;">3</span><span style="color: #0000FF;">,-</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #000000;">2</span><span style="color: #0000FF;">,</span><span style="color: #000000;">3</span><span style="color: #0000FF;">,</span><span style="color: #000000;">5</span><span style="color: #0000FF;">,</span><span style="color: #000000;">7</span><span style="color: #0000FF;">},</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_add</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;">diff</span><span style="color: #0000FF;">}}),</span>
Line 2,011:
<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;">"(%s)\n"</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">elapsed</span><span style="color: #0000FF;">(</span><span style="color: #7060A8;">time</span><span style="color: #0000FF;">()-</span><span style="color: #000000;">t0</span><span style="color: #0000FF;">))</span>
<!--</langsyntaxhighlight>-->
{{out}}
<pre>
Line 2,048:
 
=={{header|PL/I}}==
<langsyntaxhighlight lang="pli">strangeNumbers: procedure options(main);
strange: procedure(nn) returns(bit);
declare (n, nn) fixed;
Line 2,076:
end;
end;
end strangeNumbers;</langsyntaxhighlight>
{{out}}
<pre> 130 131 135 136 138 141 142 146 147 149
Line 2,089:
 
=={{header|PL/M}}==
<langsyntaxhighlight lang="pli">100H:
BDOS: PROCEDURE (F,A); DECLARE F BYTE, A ADDRESS; GO TO 5; END BDOS;
EXIT: PROCEDURE; GO TO 0; END EXIT;
Line 2,134:
END;
CALL EXIT;
EOF</langsyntaxhighlight>
{{out}}
<pre>130 131 135 136 138 141 142 146 147 149
Line 2,147:
 
=={{header|Python}}==
<langsyntaxhighlight lang="python">'''Strange Numbers'''
 
 
Line 2,205:
# MAIN ---
if __name__ == '__main__':
main()</langsyntaxhighlight>
{{Out}}
<pre>Strange numbers in range [100..500]
Line 2,222:
 
=={{header|Raku}}==
<syntaxhighlight lang="raku" perl6line>sub infix:<′>(\x,\y) { abs(x - y) ∈ (2, 3, 5, 7) }
 
my ($low,$high) = 100, 500;
Line 2,228:
 
say "Between $low and $high there are {+@strange} strange numbers:\n";
print @strange.batch(20)».fmt("%4d").join: "\n";</langsyntaxhighlight>
{{out}}
<pre>Between 100 and 500 there are 87 strange numbers:
Line 2,241:
Some optimization was added to bypass calculating the absolute value of adjacent decimal digit differences, &nbsp;
<br>as well as parsing of a number to determine the differences.
<langsyntaxhighlight lang="rexx">/*REXX pgm lists strange integers (within a range) whose decimal digs differ by a prime.*/
numeric digits 20 /*allow processing of larger numbers. */
parse arg LO HI bd . /*obtain optional arguments from the CL*/
Line 2,274:
exit 0
/*──────────────────────────────────────────────────────────────────────────────────────*/
commas: parse arg _; do jc=length(_)-3 to 1 by -3; _=insert(',', _, jc); end; return _</langsyntaxhighlight>
{{out|output|text=&nbsp; when using the default inputs:}}
<pre>
Line 2,290:
 
=={{header|Ring}}==
<langsyntaxhighlight lang="ring">
load "stdlib.ring"
 
Line 2,316:
ok
next
</syntaxhighlight>
</lang>
{{out}}
<pre>
Line 2,333:
=={{header|Ruby}}==
{{trans|Java}}
<langsyntaxhighlight lang="ruby">def digits(n)
result = []
while n > 0
Line 2,370:
xs.each_slice(10) do |s|
print s, "\n"
end</langsyntaxhighlight>
{{out}}
<pre>Strange numbers in range [100 .. 500]
Line 2,386:
 
=={{header|Sidef}}==
<langsyntaxhighlight lang="ruby">func generate_from_prefix(limit, p, base) {
 
var seq = [p]
Line 2,413:
strange_numbers(500).grep { _ > 100 }.slices(10).each{
.join(' ').say
}</langsyntaxhighlight>
{{out}}
<pre>
Line 2,430:
===Basic task===
{{trans|Go}}
<langsyntaxhighlight lang="vlang">fn is_prime(nn int) bool {
mut n := nn
if n < 0 {
Line 2,461:
}
println("\n$count strange numbers in all.")
}</langsyntaxhighlight>
 
{{out}}
Line 2,482:
=={{header|Wren}}==
===Basic task===
<langsyntaxhighlight lang="ecmascript">var primes = [2, 3, 5, 7]
var count = 0
var d = []
Line 2,500:
}
if (count % 10 != 0) System.print()
System.print("\n%(count) strange numbers in all.")</langsyntaxhighlight>
 
{{out}}
Line 2,523:
... though I've generated the 'possibles' table rather than hard-code it.
Runtime about 0.085 seconds which is quick for Wren.
<langsyntaxhighlight lang="ecmascript">var diffs = [-7, -5, -3, -2, 2, 3, 5, 7]
var possibles = List.filled(10, null)
for (i in 0..9) {
Line 2,544:
}
 
System.print("Found %(strangeOnes.count) %(places)-digit strange numbers beginning with %(start).")</langsyntaxhighlight>
 
{{out}}
Line 2,553:
=={{header|XPL0}}==
Takes 49 seconds on Raspberry Pi 4.
<langsyntaxhighlight XPL0lang="xpl0">func Strange(N);
int N, A, B, D;
[N:= N/10;
Line 2,580:
Cnt:= Cnt+1;
IntOut(0, Cnt);
]</langsyntaxhighlight>
 
{{out}}
10,333

edits