Composite numbers k with no single digit factors whose factors are all substrings of k: Difference between revisions
Content added Content deleted
m (→{{header|Wren}}: Minor tidy) |
(Added Easylang) |
||
Line 340: | Line 340: | ||
Elapsed Time: 02:39.291 min |
Elapsed Time: 02:39.291 min |
||
</pre> |
</pre> |
||
=={{header|EasyLang}}== |
|||
{{trans|C}} |
|||
<syntaxhighlight> |
|||
fastfunc is_substring n k . |
|||
pfx = k |
|||
while n > 0 |
|||
if pfx mod 10 = n mod 10 |
|||
pfx = pfx div 10 |
|||
if startMatch = 0 |
|||
startMatch = n |
|||
. |
|||
else |
|||
pfx = k |
|||
if startMatch <> 0 |
|||
n = startMatch |
|||
. |
|||
startMatch = 0 |
|||
. |
|||
if pfx = 0 |
|||
return 1 |
|||
. |
|||
n = n div 10 |
|||
. |
|||
return 0 |
|||
. |
|||
fastfunc facts_are_subs n . |
|||
if n mod 2 = 0 or n mod 3 = 0 or n mod 5 = 0 or n mod 7 = 0 |
|||
return 0 |
|||
. |
|||
factor_count = 0 |
|||
n_rest = n |
|||
factor = 11 |
|||
while factor <= n_rest |
|||
if n_rest mod factor = 0 |
|||
while n_rest mod factor = 0 |
|||
n_rest /= factor |
|||
. |
|||
if is_substring n factor = 0 |
|||
return 0 |
|||
. |
|||
factor_count += 1 |
|||
. |
|||
factor += 2 |
|||
. |
|||
if factor_count > 1 |
|||
return 1 |
|||
. |
|||
return 0 |
|||
. |
|||
n = 11 |
|||
while amount < 10 |
|||
if facts_are_subs n = 1 |
|||
print n |
|||
amount += 1 |
|||
. |
|||
n += 2 |
|||
. |
|||
</syntaxhighlight> |
|||
=={{header|F_Sharp|F#}}== |
=={{header|F_Sharp|F#}}== |