Created
March 31, 2014 20:19
-
-
Save micfan/9901310 to your computer and use it in GitHub Desktop.
公约数
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
m = 20 | |
def compute_divisor(num): | |
line = ['-' for i in range(0, 20)] | |
ret = [] | |
for _ in range(0, num): | |
if _ == 0: pass | |
elif num % _ == 0: | |
ret.append(_) | |
line[_-1] = '*' | |
ret.append(num) | |
line[num-1] = '*' | |
print ret | |
print ''.join(line) | |
for i in range(1,21): | |
print i | |
compute_divisor(i) | |
###################### | |
# 1 | |
# [1] | |
# *------------------- | |
# 2 | |
# [1, 2] | |
# **------------------ | |
# 3 | |
# [1, 3] | |
# *-*----------------- | |
# 4 | |
# [1, 2, 4] | |
# **-*---------------- | |
# 5 | |
# [1, 5] | |
# *---*--------------- | |
# 6 | |
# [1, 2, 3, 6] | |
# ***--*-------------- | |
# 7 | |
# [1, 7] | |
# *-----*------------- | |
# 8 | |
# [1, 2, 4, 8] | |
# **-*---*------------ | |
# 9 | |
# [1, 3, 9] | |
# *-*-----*----------- | |
# 10 | |
# [1, 2, 5, 10] | |
# **--*----*---------- | |
# 11 | |
# [1, 11] | |
# *---------*--------- | |
# 12 | |
# [1, 2, 3, 4, 6, 12] | |
# ****-*-----*-------- | |
# 13 | |
# [1, 13] | |
# *-----------*------- | |
# 14 | |
# [1, 2, 7, 14] | |
# **----*------*------ | |
# 15 | |
# [1, 3, 5, 15] | |
# *-*-*---------*----- | |
# 16 | |
# [1, 2, 4, 8, 16] | |
# **-*---*-------*---- | |
# 17 | |
# [1, 17] | |
# *---------------*--- | |
# 18 | |
# [1, 2, 3, 6, 9, 18] | |
# ***--*--*--------*-- | |
# 19 | |
# [1, 19] | |
# *-----------------*- | |
# 20 | |
# [1, 2, 4, 5, 10, 20] | |
# **-**----*---------* | |
# [Finished in 0.0s] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment