I am trying to create a program that prints every 100K-th basic prime number using up to 10m My code:
last = 3 res = (last) # Make the array loop: last + = 2 prime = true len = res length -1 i = 0 while (i last): break if (last% v == 0): prime = wrong, break i + = 1 if (prime): rage end (final) ) If (RS Size% 100000 == 0): Final Print if (Last> 99 99 99): Then Viz. .
But it gives the the segmentation fault (core dump)
, I wonder what's wrong?
For reference, task version:
res = [last = 3] loop final + = 2 prime = true res.each do | V | Break if v * v> Last if the last% V == 0 Prime = Falls Break and End if Prime Recovered & lt; & Lt; The final outline holds at the end if the res.length% 100000 == breaks the previous & gt; 9999999 and end
should be output:
1299721 2750161 4256249 5800139 7368791 8960467
And no, this one There is no homework, just out of curiosity.
You found it great, by yourself! It is called println
. says
in medicine. And it crashed in res size
.
For example, use it for debugging: rm config.inc DEBUG = 1 bin / drug-D-DTT example / 100thoddprime.pn
And then press until you reach the accident.
(example / 100thoddprime.pn: 18): res append (last)
& gt;
; (3, 5) [9 5] Sociable 1 1; (3, 5) [9 6] 2 1; (3, 5) [9 7] load 1 1 5; Size [98] Tie 1 2; Function size () [99] Load 3pp; Zero [100] Call 1 3 Partition fault
The size on the leak became so low, and the accident occurred.
and instead of the previous print, print "N".
just do last.
It came from perl6 syntax, sorry :)
No comments:
Post a Comment