找见问题所在了: Private Const p1 As String = "{2,3,5,7,11,13,17,19,23,29,31,37,41,43,47}"
Private Const p2 As String = "{6,10,14,15,21,22,25,26,33,34,35,38,39,46}"
Function powercount(ByVal r As Range) As Long powercount = Evaluate("SUMPRODUCT(INT(" & r & "^(1/" & p1 & ")))-SUMPRODUCT(INT(" & r & "^(1/" & p2 & ")))") '前者15个质数,1被计数15次,后者14个质数,1被计数14次,正好抵消 End Function
Private Const p2 As String = "{6,10,14,15,21,22,26,33,34,35,38,39,46}" '1,2的误差发生在2^25,3^25 处,由于指数完全平方数时不会被重复计数,故25不应计数在内 Function powercount(ByVal r As Range) As Long powercount = Evaluate("SUMPRODUCT(INT(" & r & "^(1/" & p1 & ")))-SUMPRODUCT(INT(" & r & "^(1/" & p2 & ")))") - 1 '前者15个质数,1被计数15次,后者13个质数,1被计数13次,总计多计1次,故减1 End Function
Function maxpower(ByVal r As Range) As String Dim largest As Double, power As Byte, p3 As String largest = Evaluate("MAX(INT(" & r & "^(1/" & p1 & "))^" & p1 & ")") p3 = largest & "^(1/" & p1 & "))" power = Evaluate("1/Max((INT(" & p3 & "=" & p3 & "*(1/" & p1 & "))") maxpower = largest & "=" & largest ^ (1 / power) & "^" & power End Function |