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

→‎{{header|Wren}}: Added a simple optimization & rewrote preamble.
(→‎{{header|Phix}}: prepand pascal, a little bit lengthy)
(→‎{{header|Wren}}: Added a simple optimization & rewrote preamble.)
Line 771:
{{libheader|Wren-math}}
{{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).
 
ThisRuntime takesabout just under 43 minutes to36 runseconds 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
import "./fmt" for Fmt
Line 809:
}
i = i + 1
if (i % 8 == 0 || i % 27 == 0) i = i + 1
}</syntaxhighlight>
 
9,488

edits