Greatest prime dividing the n-th cubefree number: Difference between revisions

Content added Content deleted
(→‎{{header|Phix}}: prepand pascal, a little bit lengthy)
(→‎{{header|Wren}}: Added a simple optimization & rewrote preamble.)
Line 771: Line 771:
{{libheader|Wren-math}}
{{libheader|Wren-math}}
{{libheader|Wren-fmt}}
{{libheader|Wren-fmt}}
Simple brute force approach though skipping numbers which are multiples of 8 or 27 as these can't be cubefree.
This takes just under 4 minutes to run on my system (Core i7).


Runtime about 3 minutes 36 seconds on my system (Core i7).
Although it looks odd that the 1 millionth and 10 millionth terms are the same (and I have no independent source to check against), it would appear that the 1 millionth cubefree number is 1,202,057 which is prime and the 10 millionth such number is coincidentally 10 times this.
<syntaxhighlight lang="wren">import "./math" for Int
<syntaxhighlight lang="wren">import "./math" for Int
import "./fmt" for Fmt
import "./fmt" for Fmt
Line 809: Line 809:
}
}
i = i + 1
i = i + 1
if (i % 8 == 0 || i % 27 == 0) i = i + 1
}</syntaxhighlight>
}</syntaxhighlight>