1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
(*可以直接用LiouvilleLambda,但比这个略慢一些*)
PCType[n_] := If[EvenQ@PrimeOmega@n, 1, -1];
blocksize = 10^7; (*分成91组计算,每组1千万*)
blocks = 91;
(bks = ParallelTable[Total[PCType[(i - 1)*blocksize + #] & /@ Range[blocksize]],
{i, blocks}];) // AbsoluteTiming
{4023.83, Null}
(*一泻千里*)
acc = Accumulate@bks
{-842, -4510, -5630, -3192, -7608, -3016, -6598, -7132, -2176, -3884,
-10162, -8592, -11162, -5636, -3244, -7206, -10696, -17010, -15562,
-11126, -9698, -4922, -6086, -9594, -7970, -9628, -14754, -17252,
-16346, -16648, -17882, -12168, -11464, -6452, -8508, -4110, -4244,
-8500, -11184, -11200, -14386, -14942, -19500, -20456, -24366,
-23732, -22644, -19746, -18196, -18804, -11604, -11950, -10062,
-7442, -6866, -5544, -6456, -9230, -11014, -15350, -15668, -14892,
-18936, -20766, -20196, -21820, -22404, -27546, -22948, -25384,
-27772, -26580, -25558, -25602, -27618, -22166, -15564, -15628,
-15656, -19292, -17546, -19704, -19386, -19754, -14908, -17416,
-13780, -12306, -8570, -4630, -4702}
(lastblock = ParallelTable[PCType[(blocks - 1)*blocksize + i],
{i, blocksize}];) // AbsoluteTiming
{47.6069, Null}
lastacc = acc[[90]] + Accumulate@lastblock;
SelectFirst[lastacc, Positive]
1
FirstPosition[lastacc, 1]
{6150257}
MinMax@lastacc
{-6077, 829}
Count[lastacc, _?Positive]
305426
Position[overall, 1][[{1, -1}]]
{{6150257}, {6488079}}
|