python circle nested

#!/usr/bin/python
# -*- coding:utf-8 -*-

# @filename: tmp2
# @author:vickey
# @date: 2017/10/23 17:05


def circle_nested(total, inside):
    for i in range(1, total + 1):

        if i > inside:                                    # i = 11
            j = i - inside * ((i - 1) / inside)
            print(i, j)
        else:
            print(i, i)

circle_nested(13, 3)

效果:

(1, 1)
(2, 2)
(3, 3)
(4, 1)
(5, 2)
(6, 3)
(7, 1)
(8, 2)
(9, 3)
(10, 1)
(11, 2)
(12, 3)
(13, 1)

原文地址:https://www.cnblogs.com/vickey-wu/p/7844419.html