Composite numbers k with no single digit factors whose factors are all substrings of k: Difference between revisions
Content added Content deleted
Line 342: | Line 342: | ||
=={{header|EasyLang}}== |
=={{header|EasyLang}}== |
||
{{trans|C}} |
{{trans|C}} (optimized) |
||
<syntaxhighlight> |
<syntaxhighlight> |
||
fastfunc |
fastfunc isin n k . |
||
h = k |
|||
while n > 0 |
while n > 0 |
||
if |
if h mod 10 = n mod 10 |
||
h = h div 10 |
|||
if |
if match = 0 |
||
match = n |
|||
. |
. |
||
else |
else |
||
h = k |
|||
if |
if match <> 0 |
||
n = |
n = match |
||
. |
. |
||
match = 0 |
|||
. |
. |
||
if |
if h = 0 |
||
return 1 |
return 1 |
||
. |
. |
||
Line 366: | Line 366: | ||
return 0 |
return 0 |
||
. |
. |
||
fastfunc |
fastfunc test n . |
||
if n mod 2 = 0 or n mod 3 = 0 or n mod 5 = 0 or n mod 7 = 0 |
if n mod 2 = 0 or n mod 3 = 0 or n mod 5 = 0 or n mod 7 = 0 |
||
return 0 |
return 0 |
||
. |
. |
||
rest = n |
|||
fact = 11 |
|||
while fact <= rest |
|||
if rest mod fact = 0 |
|||
while factor <= n_rest |
|||
while rest mod fact = 0 |
|||
rest /= fact |
|||
n_rest /= factor |
|||
. |
. |
||
if |
if isin n fact = 0 |
||
return 0 |
return 0 |
||
. |
. |
||
nfacts += 1 |
|||
. |
. |
||
fact += 2 |
|||
if |
if fact > sqrt n and nfacts = 0 |
||
return 0 |
return 0 |
||
. |
. |
||
. |
. |
||
if |
if nfacts > 1 |
||
return 1 |
return 1 |
||
. |
. |
||
Line 394: | Line 394: | ||
. |
. |
||
n = 11 |
n = 11 |
||
while |
while count < 10 |
||
if |
if test n = 1 |
||
print n |
print n |
||
count += 1 |
|||
. |
. |
||
n += 2 |
n += 2 |