Deceptive numbers: Difference between revisions

Content added Content deleted
m (→‎{{header|Free Pascal}}: 1e6 from 5min -> 2 min 35 -> 1 min 10)
(→‎{{header|Wren}}: As pointed out by Nigel, repunits can't be divisible by 5.)
Line 301: Line 301:
{{libheader|Wren-gmp}}
{{libheader|Wren-gmp}}
{{libheader|Wren-math}}
{{libheader|Wren-math}}
An embedded program so we can use GMP. Takes 0.021 seconds to find the first 25 deceptive numbers.
An embedded program so we can use GMP. Takes 0.019 seconds to find the first 25 deceptive numbers.

The first 62 deceptive numbers (up to 97681 though not shown in full) are found in 0.179 seconds.
<lang ecmascript>/* deceptive_numbers.wren */
<lang ecmascript>/* deceptive_numbers.wren */


Line 313: Line 315:
var deceptive = []
var deceptive = []
while (count < limit) {
while (count < limit) {
if (!Int.isPrime(n) && n % 3 != 0) {
if (!Int.isPrime(n) && n % 3 != 0 && n % 5 != 0) {
if (repunit.isDivisibleUi(n)) {
if (repunit.isDivisibleUi(n)) {
deceptive.add(n)
deceptive.add(n)