Is a positive number s and the sequence -python

Ideas: Reference Method 4 https://blog.csdn.net/qq_41822235/article/details/82109081 inside
while python2.7 reasons, the division will omit decimals, IF statement is added, where I J = 2 = Tsum,

# -*- coding:utf-8 -*-
class Solution:
    def FindContinuousSequence(self, tsum):
        # write code here
        res = []
        for i in range((tsum)//2+1, 1, -1):
            j = 2*tsum / i
            if i*j == 2*tsum and (j-i+1)>0 and (j-i+1) % 2 == 0:
                res.append([ii+(j-i+1)/2 for ii in range(i)])
        return res

Guess you like

Origin www.cnblogs.com/dolisun/p/11332087.html