dunhee
发表于 2018-3-12 16:53:59
def fac(n):
if n == 1: return 1
else: return fac(n-1)*n
def genS(n):
return ''.join()
def p(n):
s = genS(n)
n = 1
L = []
while s:
L.append(])
s = s
n += 1
return L
for in p(50):
print('({:>2}) {}'.format(x,y))
jfmlj
发表于 2018-3-12 17:05:59
def fact(x):
result = 1
for i in range(2,x + 1):
result *= i
return result
list1=str(fact(1))
for i in range(2,51):
list1=list1+str(fact(i))
count=0
y=1
for j in range(y):
print('('+str(y)+')',end=' ')
for i in list1:
print(i,end='')
count += 1
if(count%40==0):
print(end='\n')
y+=1
print('('+str(y)+')',end=' ')
凹凸曼呵呵哒
发表于 2018-3-12 18:09:44
#计算阶乘函数
def factorial(num):
x = 1
for i in range(num+1):
if i > 0:
x *= i
return x
if __name__ == '__main__':
tal = inx = ''
line = 0
for j in range(51):
if j>0:
inx += str(factorial(j))
for i in range(len(inx)):
if not(i%40):
line += 1
if len(str(line)) == 1:
tal = ' '
elif len(str(line)) == 2:
tal = ''
print('(%s%d)'%(tal, line),inx)
luokaoge
发表于 2018-3-12 18:50:01
#创建初始值
a = 1
ls =
#生成1-50的阶乘,并将结果追加到列表中
for i in range(2,50):
a= a*i
b= str(a)
ls.append(b)
#将列表中的所有阶乘拼接到一起
factorial = '1'
for i in range(1,49):
factorial = factorial + ls
#以40为分界点打印结果
L=len(factorial)
B=int(L/40)
for i in range(1,B):
#为个位数字添加空格
if i<10:
e = str(i)
a = ' '+ e
else:
a = str(i)
b = '('+ a + ')'
c = 39*i
d = 39*(i-1)
#print(b)
print(b+ '' + factorial)
#追加余数列
C=B*40
D=str(B)
E = '('+ D + ')'
print(E + '' + factorial)
luokaoge
发表于 2018-3-12 19:03:57
#初学者,再循环下列表d_d
#创建初始值
a = 1
ls =
#生成1-50的阶乘,并将结果追加到列表中
for i in range(2,50):
a= a*i
b= str(a)
ls.append(b)
#将列表中的所有阶乘拼接到一起
factorial = '1'
for i in ls:
a = str(i)
factorial = a + factorial
#以40为分界点打印结果
L=len(factorial)
B=int(L/40)
for i in range(1,B):
#为个位数字添加空格
if i<10:
e = str(i)
a = ' '+ e
else:
a = str(i)
b = '('+ a + ')'
c = 39*i
d = 39*(i-1)
#print(b)
print(b+ '' + factorial)
C=B*40
D=str(B)
E = '('+ D + ')'
#追加余数列
print(E + '' + factorial)
lyjlyj
发表于 2018-3-12 19:15:27
#coding=utf-8
def factorial(n):
sum = 1
for i in range(1,n+1):
sum *= i
return sum
str_num = ""
#将所有的阶乘转换成字符并连接起来
for item in range(1,51):
num = factorial(item)
str_num += str(num)
n = 0#限制每行的个数
flag = 1#用于输出行数
for item in str_num:
if n%40 == 0:
print ("(%d) "%(flag),end="")
print (item,end="")
n += 1
if n >= 40:
n = 0
flag += 1
print("")
gkj111111
发表于 2018-3-12 19:49:12
def fun(n):
num=1
for each in range(1,n+1):
num=each*num
return num
n=1
str_p=''
while n<=50:
num_l=fun(n)
str_p+=str(num_l)
n+=1
r=len(str_p)//40+1
for line in range(1,r+1):
print('('+str(line).rjust(2)+') '+str_p[:40])
str_p=str_p
newbieofnewbie
发表于 2018-3-12 20:34:54
def calculate():
i=0
begi=1
se=1
al=1
temp=''
while al<51:
temp=temp+str(se)
se=se*(al+1)
al+=1
a=0
b=40
length=len(temp)
while length>=40:
print('(',begi,')',end='')
begi+=1
print(temp)
a+=40
length-=40
print('(', begi, ')',end='')
print(temp)
if __name__=='__main__':
calculate()
_小菜鸟
发表于 2018-3-12 21:10:53
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
fan1993423
发表于 2018-3-12 21:52:23
def f(x):
i=1
p=1
while i<=x:
p=p*i
i+=1
return p
m=int(input('请输入一个正整数,拼接1的阶乘到这个数的阶乘'))
l=''
for n in range(1,m+1):
l=l+str(f(n))
for t in range(0,len(l)//40+1):
q=t+1
print(('(%d)'+''+l)%q)
此用户不合法
发表于 2018-3-12 23:07:28
def Factorial(n):
if n == 0:
return 1
else:
k=1
for i in range(1,n+1):
k = k*i
return k
string = ''
for each in range(1,51):
string = string+str(Factorial(each))
linenumber = len(string)//40
for line in range(1,linenumber+1):
print('(%2d)'%line+' '+string[(line-1)*40:line*40])
print('(%2d)'%line+' '+string)
elang696
发表于 2018-3-13 08:52:43
def factorial(i):
result = 1
for x in range(1,i+1):
result = result * x
return result
def join_fact(i):
result = ''
temp = []
for x in range(1,i+1):
temp.append(str(factorial(x)))
result = ''.join(temp)
return result
def print_result(i):
result = join_fact(i)
count = len(result) // 40
row = 1
for x in range(count):
print("(%2d)"%row,end=' ')
print(result)
row += 1
print("(%2d)"%row,end=' ')
print(result)
if __name__ == '__main__':
print_result(50)
大头目
发表于 2018-3-13 09:24:19
import math
def fac_plus(n):
fac_plus_out = ''
for i in range(1, n+1):
each = math.factorial(i) #阶乘函数
each_s = str(each)
fac_plus_out += each_s
#print(fac_plus_out)
return fac_plus_out
#fac_plus(7)
def cut_each(s):
start = 0
end = 40
t = 1
while True:
sp = s
if len(sp):
print('(',t,')',sp)
t +=1
start += 40
end += 40
else:
break
cut_each(fac_plus(50))
lcfyujianwen
发表于 2018-3-13 11:37:09
def fun(n):
if n ==1:
return 1
else:
return (n*fun(n-1))
with open (r'C:\Users\lcfyujianwen\Desktop\jiecheng.txt', 'w') as f:
pass
for i in range(1,51):
with open (r'C:\Users\lcfyujianwen\Desktop\jiecheng.txt', 'a') as f:
f.write(str(fun(i)))
with open (r'C:\Users\lcfyujianwen\Desktop\jiecheng.txt', 'r+') as k, open (r'C:\Users\lcfyujianwen\Desktop\jie.txt', 'a') as g:
num = len(k.read())
k.seek(0)
s = k.read()
n = 1
g.write('( 1)')
m =1
for i in range(num):
g.write(s)
if n == 40:
m+=1
g.write('\n')
g.write('(%2d)'%m)
n = 0
n +=1
所向故往
发表于 2018-3-13 13:33:03
#定义一个计算阶乘的函数
deffactorial(n):
if n == 1:
return 1
return n * factorial(n-1)
L = [] #将阶乘结果放进这个列表中
V = '' #将列表中的阶乘结果利用字符串的性质加起来
#通过循环实现上述目标
for i in range(1,51):
L.append(str(factorial(i)))
for i in L:
V += i
#输出结果
if int(len(V)) > (int(int(len(V))/40) * 40):
num_P = int(int(len(V))/40+1) #行,python的计算式省略了小数位
else:
num_P = int(int(len(V))/40+1)
num_C = 0 #记录四十个
for i in range(1,num_P+1):#利用切片,实现每四十个为一组输出
print('(',i,')','',V)
num_C += 40
瞬秒爆加速
发表于 2018-3-13 14:25:36
import math
def fun():
a = "".join()
for i in range(len(a)//40+1):
print("(%-3d)%s" % (i+1,a))
if __name__=="__main__":
fun()
yunying12321
发表于 2018-3-13 22:29:30
def fun(n):
#定义阶乘函数
result = 1
for i in range(1, n+1):
result *= i
return result
def main():
gg = 50
str_gg = ''
#将1-50的阶乘分别转化为字符串类型,并合并到一个字符串里
for i in range(1,gg+1):
str_gg += str(fun(i))
#计算按要求排列得到的行数
str_length = len(str_gg)
str_row = str_length//40 + 1
#根据题目要求进行排列
for i in range(1, str_row+1):
if i < 10:
print('( ' , i, ')' ,' ', end=' ')
print(str_gg[((i-1)*40):(i*40)])
else:
print('(' , i, ')' ,' ', end=' ')
print(str_gg[((i-1)*40):(i*40)])
if __name__ == "__main__":
main()
结果:
(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
2012277033
发表于 2018-3-13 23:16:00
import re
def jiecheng(a):
if a==1:
return 1
else:
return jiecheng(a-1)*a
strs=""
for i in range(1,51):
strs+=str(jiecheng(i))
str_list=re.findall(r'.{40}',strs)
num=1
for item in str_list:
print("(%d)\t%s"%(num,item))
num+=1
坑得飞起
发表于 2018-3-13 23:51:47
cj=1
zh=0
for i in range(1,51):
cj*=i
zh=int(str(zh)+str(cj))
zh=str(zh)
for i in range(1,10):
print('( '+str(i)+') ',zh)
zh=zh
for i in range(10,36):
print('('+str(i)+') ',zh)
zh=zh
print('(36) ',zh)
Andy0214
发表于 2018-3-14 09:19:48
不会加行标from __future__ import print_function
import math
facl = 1
num = []
count=0
for i in range(1,51):
fac = math.factorial(i)
num.append(fac)
num1 = list(''.join(map(str,num)))
for j in num1:
print(j,end='')
count += 1
if(count%40==0):
print(end='\n')