BlueSand
发表于 2018-3-14 19:32:58
allstr = ""
j = 1
for i in range(1, 51):
j = j * i
allstr = allstr + str(j)
for j in range(0, len(allstr), 40):
print("("+str(j // 40 + 1) + ")", allstr)
linghushaoxia33
发表于 2018-3-14 20:33:15
def jc(n): #封装一个阶乘函数
rst = 1
for i in range(1,n+1):
rst *= i
return str(rst)
s = ''
for i in range(1,51): #拼接1~50的结果结果
s = s + jc(i)
for i in range (0,(len(s)//40)+1):
print('({}) {} '.format(i+1, s[(i*40):(39+i*40)]))
冬雪雪冬
发表于 2018-3-14 20:49:59
评分截至标记。
溯影
发表于 2018-3-14 20:59:03
°蓝鲤歌蓝 发表于 2018-3-11 16:49
勉强一行?
老铁厉害,但是程序可读性不是很高咯{:10_243:}(分析ing。。。)
°蓝鲤歌蓝
发表于 2018-3-14 21:02:35
溯影 发表于 2018-3-14 20:59
老铁厉害,但是程序可读性不是很高咯(分析ing。。。)
所以我三种都写出来了。考虑可读性的话就看第一种。
°蓝鲤歌蓝
发表于 2018-3-14 21:15:31
°蓝鲤歌蓝 发表于 2018-3-11 16:49
勉强一行?
沾大佬的光。
溯影
发表于 2018-3-14 22:56:42
°蓝鲤歌蓝 发表于 2018-3-14 21:02
所以我三种都写出来了。考虑可读性的话就看第一种。
嗯嗯,学习了!{:5_110:}
小辛呀小辛
发表于 2018-3-15 03:10:07
def fac(number):
if(number==1 or number==0):
return 1
else:
return fac(number-1)*number
if __name__=='__main__':
res=''
for i in range(1,51):
res = res + str(fac(i))
cnt = 0
line_num = 1
print('(%d)'%line_num,end='')
for a in res:
cnt = cnt + 1
print(a,end='')
if cnt%40 == 0:
print('')
line_num+=1
print('(%d)'%line_num,end='')
gopythoner
发表于 2018-3-15 15:51:06
from functools import reduce
import time
def add_num(n):
num = reduce(lambda x, y: x * y, range(1, n + 1))
return str(num)
def to_str(n):
l = reduce(lambda x, y: x + y, map(add_num, range(1, n + 1)))
return l
def get_result(n, k):
s = to_str(n)
m = int(len(s) / k)
dic = dict()
for i in range(1, m + 1):
dic = s
if len(s) % k:
dic = s
for each in dic:
print('({}){} '.format(each, dic))
if __name__ == '__main__':
t = time.time()
get_result(50, 40)
print(time.time() - t)
grf1973
发表于 2018-3-15 16:45:10
第一次发贴。。。。。。
s=''
v=1
n=0
for i in range(1,51):
v*=i
s+=str(v)
while len(s)>40:
n+=1
print("("+str(n)+") "+s[:40])
s=s
_小菜鸟
发表于 2018-3-16 09:26:25
def factorial(n):
if n == 1 or n==0:
return 1
else:
return (n)*factorial(n-1)
if __name__ == "__main__":
n = input("输入阶乘n:")
str1 = ''
i,j,k = 1,1,0
while(i <= n):
str2 = str(factorial(i))
str1 = str1+str2
i += 1
while(j <= len(str1)):
if j % 40 == 0:
print("(%d) %s" % (k,str1[(j-40):j]))
k += 1
if j == len(str1) :
print("(%d) %s" % (k,str1))
j += 1
十一11
发表于 2018-4-3 23:46:49
def f(n):
result = 1
for i in range(1,n+1):
result *= i
return result
list1 = []
for n in range(1,51):
list1.append(str(f(n)))
str1 = ''.join(list1)
for a in range(len(str1) // 40 + 1):
print(str1)
chongchuigu
发表于 2018-7-14 22:13:22
import math
s=''
count=1
num=0
for i in range(1,51):
s+=str(math.factorial(i))
print('(%2d) ' % count,end='')
i=0
while i < len(s):
num+=1
if num!=41:
print(s,end='')
i+=1
else:
count+=1
print()
num=0
print('(%2d) ' % count,end='')
小木子c
发表于 2018-7-20 20:36:19
str1 = ''
for i in range(1,51):
t = 1
while i:
t *= i
i -= 1
str1 += str(t)
list2 = list(str1)
count = 0
row = 1
print('(',row,')',end=' ')
for each in list2:
print(each,end='')
count += 1
if count % 40 == 0:
row += 1
print(end='\n')
print('(',row,')',end=' ')
子沙
发表于 2018-10-12 14:30:54
def jieCheng(num):
result,num1=1,num
while num1!=1:
result,num1=result*num1,num1-1
return result
i,j=1,1
str1=str(jieCheng(i))
while i<50:
while len(str1)<40:
str1,i=str1+str(jieCheng(i+1)),i+1
print('(%2d)' %(j),'',str1[:40])
str1,j=str1,j+1
while len(str1)>40:
print('(%2d)' %(j),'',str1[:40])
str1,j=str1,j+1
print('(%2d)' %(j),'',str1[:40])
喜欢吃菠菜
发表于 2018-10-12 15:57:56
本帖最后由 喜欢吃菠菜 于 2018-10-12 16:22 编辑
fac=lambda n:1 if n==1 else n*fac(n-1)
s=''.join(('{}'.format(fac(n)) for n in range(1,51)))
line=1
while s:
s,tmp=s,s[:41]
print('(%2d)%s ' % (line,tmp))
line+=1
776667
发表于 2019-1-4 10:41:00
def fun162(x):
def factorial(y):
result = 1
for i in range(1,y+1):
result *= i
return result
str_a = ''.join()
list_a = []
while len(str_a)>=40:
list_a.append(str_a[:40])
str_a = str_a
list_a.append(str_a)
line = 1
for i in list_a:
if line < 10:
print('( %s)%s'%(line,i))
else:
print('(%s)%s'%(line,i))
line += 1
if __name__ == '__main__':
fun162(50)
( 1)1262412072050404032036288036288003991680
( 2)0479001600622702080087178291200130767436
( 3)8000209227898880003556874280960006402373
( 4)7057280001216451004088320002432902008176
( 5)6400005109094217170944000011240007277776
( 6)0768000025852016738884976640000620448401
( 7)7332394393600001551121004333098598400000
( 8)0403291461126605635584000000108888694504
( 9)1835216076800000030488834461171386050150
(10)4000000884176199373970195454361600000026
(11)5252859812191058636308480000000822283865
(12)4177922817725562880000000263130836933693
(13)5301672180121600000008683317618811886495
(14)5181944012800000002952327990396041408476
(15)1860964352000000010333147966386144929666
(16)6513375232000000003719933267899012174679
(17)9944815083520000000013763753091226345046
(18)3159795815809024000000005230226174666011
(19)1176000722410007429120000000020397882081
(20)1974433586402817399028973568000000008159
(21)1528324789773434561126959611589427200000
(22)0000334525266131638071081700620534407516
(23)6515200000000014050061177528798985431426
(24)0624451156993638400000000060415263063373
(25)8356373551320685139975072645120000000002
(26)6582715747884487680436258110146158903196
(27)3852800000000011962222086548019456196316
(28)1495657715064383733760000000000550262215
(29)9812088949850305428800254892961651752960
(30)0000000002586232415111681806429643551536
(31)1197996919763238912000000000012413915592
(32)5360726708622890473733750385214863546777
(33)6000000000060828186403426756087225216332
(34)1295376887552831379210240000000000304140
(35)9320171337804361260816606476884437764156
(36)8960512000000000000
foxiangzun
发表于 2019-1-20 16:39:25
def getFactorial(num) :
temp = 1
for i in range(1, num + 1) :
temp *= i
return temp
def spellNum() :
list1 =
list2 = list(''.join(list1))
lineNum, flag = 1, 0
print('[' + str(lineNum) + '] ', end='')
lineNum += 1
for i in list2 :
if flag != 39 :
print(i, end='')
flag += 1
else :
flag = 0
print(i)
print('[' + str(lineNum) + '] ', end='')
lineNum += 1
spellNum()
注册列表
发表于 2019-1-20 17:36:36
def f(x):
y=1
for i in range(1 , x+1):
y=y*i
return y
st=""
n=0
y=""
for i in range(1,51):
st=st+str(f(i))
for i in st:
y=y+i
n+=1
ifn % 40==0:
print("(",str(int(n/40))+")\t"+y)
y=""
小贤啊哦
发表于 2020-6-4 19:19:56
def fun110(n):
s=[]
for i in range(1,n+1):
a=1
for j in range(1,i+1):
a*=j
s.append(a)
return s
def sss(n):
r=''
s=fun110(n)
for z in s:
r=r+str(z)
if len(r)%40==0:
for k in range(1,len(r)//40+1):
print(str(k)+' '+r[(k-1)*40:40*k])
else:
for i in range(1,len(r)//40+2):
print('('+str(i)+')'+' '+r[(i-1)*40:i*40])