大数乘法 python

def fun(num1,num2):
    #num1 type str
    #num2 type str
    a = map(int,list(reversed(num1)))
    b = map(int,list(reversed(num2)))
    result = [0]*(len(a) + len(b))
    for ia,va in enumerate(a):
        c = 0
        for ib,vb in enumerate(b):
            tmp = va*vb + c + result[ia+ib] 
            result[ia+ib] = tmp % 10
            c = tmp / 10
        result[ia+ib+1] = c
    result = result[::-1]
    print result

fun('254954058045047604584','25343434358748574957945794759475948759475945794')
    原文作者:大整数乘法问题
    原文地址: https://blog.csdn.net/lxg0807/article/details/78087335
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞