轻拔琴弦|剑指 Offer 64. 求1+2+…+n-leetcode( 二 )

<< i) and A) << i))return quickMultiply(0) >> 1# 快速乘法的常规实现def quickMultiply2(A, B):res = 0for i in range(32):if B < 1 << i:breakif B & 1 << i:res += A << ireturn resreturn quickMultiply2(n, n + 1) >> 1参考资料[1]
原题链接:


推荐阅读