Largest difference between adjacent primes/Factor: Difference between revisions
Largest difference between adjacent primes/Factor (view source)
Revision as of 01:20, 20 November 2021
, 2 years agofix vestigial code
(add detailed explanation) |
m (fix vestigial code) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 3:
lprimes dup cdr lzip [ first2 2dup swap - -rot 3array ] lmap-lazy
[
"Largest difference in adjacent primes under a million: %d between %d and %d.\n" vprintf</lang>
Line 91:
|
|
| <tt>L{ { 1 2 3 } { 2 3 5 } { 2 5 7 } { 4 7 11 } ... }</tt>
|-
| <tt>[ second 1e6 < ] lwhile</tt>
Line 100:
| take the maximum element, using <tt>{ 0 }</tt> as a seed
| <tt>{ 114 492113 492227 }</tt>
|}
At this point, we simply use <tt>vprintf</tt> to output the answer. <tt>vprintf</tt> is like <tt>printf</tt> except it takes its arguments from a sequence instead of the data stack.
|