Skip to content

Commit

Permalink
fixes #973 (#1045)
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-henz authored Jul 10, 2024
1 parent be8b528 commit dbae760
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions xml/chapter1/section2/subsection6.xml
Original file line number Diff line number Diff line change
Expand Up @@ -657,12 +657,13 @@ function timed_prime_test(n) {
function start_prime_test(n, start_time) {
return is_prime(n)
? report_prime(get_time() - start_time)
: true;
: false;
}
<SHORT_SPACE_AND_ALLOW_BREAK/>
function report_prime(elapsed_time) {
display(" *** ");
display(elapsed_time);
return true;
}
</JAVASCRIPT>
</SNIPPET>
Expand Down Expand Up @@ -726,8 +727,8 @@ function search_for_primes(start, times) {
? true
: start &gt; 2 &amp;&amp; start % 2 === 0
? search_for_primes(start + 1, times)
// if we get undefined -&gt; its a prime
: is_undefined(timed_prime_test(start))
// if we get true, it's a prime
: timed_prime_test(start)
? search_for_primes(start + 2, times - 1)
: search_for_primes(start + 2, times);
}
Expand All @@ -740,8 +741,8 @@ function search_for_primes(start, times) {
<REQUIRES>search_for_primes_definition</REQUIRES>
<JAVASCRIPT>
search_for_primes(10000, 3);
// search_for_primes(100000, 3);
// search_for_primes(1000000, 3);
// search_for_primes(10000000, 3);
// search_for_primes(10000000000, 3);
</JAVASCRIPT>
<SCHEME>
</SCHEME>
Expand Down

0 comments on commit dbae760

Please sign in to comment.