子沙
发表于 2018-9-11 22:21:04
本帖最后由 子沙 于 2018-9-11 22:22 编辑
def fun_207(num):
x1,x2=1,1
x1,x2=x2,x1+x2
num1=0
while num1<num:
x1,x2=x2,x1+x2
if len(str(x2))>1:
flag=0
for i in sorted(set(list(map(lambda x:int(x),list(str(x2))))),reverse=True):
if i!=0:
if x2%i!=0:
flag=1
break
if flag==0:
print(x2)
num1+=1
fun_207(10)
运行结果如下:
55
144
46368
5358359254990966640871840
64202014863723094126901777428873111802307548623680
769246427201094785080787978422393713094534885688979999504447628313150135520
9216845717656874712980450562726202415567360565980794777111390850331644813674856981646960226192287360
110433070572952242346432246767718285942590237357555606380008891875277701705731473925618404421867819924194229142447517901959200
1323171012053243520828784042795469593341319770463238313551473338336502410952765153371119398122747569819754164672344667591018783803781288766524146031040
15853779289614481577191691577533518174485949824765525957623037737532160833631593681512535189759649213804709691705593604227037581022758330489263385511067756715301085561591382880
瓦蓝
发表于 2018-9-11 22:28:09
本帖最后由 瓦蓝 于 2018-9-11 22:37 编辑
a,b=5,8
def fab():
global a,b
a,b=b,a+b
c=b%2520
n=set(str(b))
try:
n.remove('0')
n.remove('1')
except:pass
for i in n:
if c%int(i):fab()
print(b)
fab()
fab()
Legend丶Hu
发表于 2018-9-11 22:39:31
def sum(n):
p = {}
s = 0
temp = n
while n:
p = 1
n //= 10
if p.get(9) and p.get(3):
p.pop(3)
if p.get(8):
if p.get(4):
p.pop(4)
if p.get(2):
p.pop(2)
if p.get(4) and p.get(2):
p.pop(2)
if p.get(6):
if p.get(3):
p.pop(3)
if p.get(2):
p.pop(2)
if p.get(0):
p.pop(0)
flag = 1
for each in p:
if temp % each != 0:
flag = 0
break;
return flag
a =
for i in range(2,900):
t = a + a
a.append(t)
cnt = 0
for each in a:
if cnt == 10:
break;
if each > 8 and sum(each):
cnt += 1
print(each)
55
144
46368
5358359254990966640871840
64202014863723094126901777428873111802307548623680
769246427201094785080787978422393713094534885688979999504447628313150135520
9216845717656874712980450562726202415567360565980794777111390850331644813674856981646960226192287360
110433070572952242346432246767718285942590237357555606380008891875277701705731473925618404421867819924194229142447517901959200
1323171012053243520828784042795469593341319770463238313551473338336502410952765153371119398122747569819754164672344667591018783803781288766524146031040
15853779289614481577191691577533518174485949824765525957623037737532160833631593681512535189759649213804709691705593604227037581022758330489263385511067756715301085561591382880
CoderWGB
发表于 2018-9-11 22:41:43
def aliquot(num):
if '0' in str(num):
return False
else:
for i in range(len(str(num))):
if num%int(str(num)) == 0:
return True
else:
return False
def fibsNum():
a = 0
b = 1
num_list = []
while True:
a,b = b,a+b
if a > 10:
zc_status = aliquot(a)
if zc_status is True:
num_list.append(a)
if len(num_list) == 10:
return num_list
print(fibsNum())
#
久疤K
发表于 2018-9-11 23:18:28
>>> def maxYs( x, y ):
x,y = (x,y) if x < y else (y,x)
while x:
x,y = y%x, x
return y
>>> def minBs( *ns ):
r = 1
for n in ns:
if n:
r = r * n // maxYs(r,n)
return r
>>> minBs(4,6)
12
>>> def fb():
a,b=1,1
while True:
yield a
a,b = b,a+b
>>> def fun( n = 10 ):
res = []
f = fb()
cnt = 0
while cnt < n:
t = next(f)
if t < 10:
continue
if t % minBs(*) == 0:
cnt += 1
res.append( t )
return res
>>> fun()
>>>
RIXO
发表于 2018-9-11 23:41:51
a,b,n=1,1,0
while n<10:
count = 1
b,a=a+b,b
for x in set(str(b)):
if int(x) != 0:
if b%int(x) != 0:
count = 0
if b > 10 and count:
n += 1
print(n,b)
grf1973
发表于 2018-9-12 10:40:15
def check(n):
res=
for x in map(int,set(str(n))):
res=1
if res==1:
res=0
if res==1:
res=0
res=0
if res==1:
res=0
res=0
if res==1:
res=0
for x in ==1]:
if n%x>0:
return False
return True
a,b,n=5,8,0
while n<10:
b,a=a+b,b
if check(b):
n+=1
print(n,b)
apple_wt
发表于 2018-9-12 10:57:12
def fib():
a,b=8,13
while True:
a,b=b,a+b
d = str(a) #将整型数转化为字符
c = map(int,d) #将字符串的每一位取出来转化未整型,再返回一个列表
f = map(int,d) #将字符串的每一位取出来转化未字符,再返回一个列表
m = set(f)
e = list(m)
#print(e)
length = len(e)
#print(length)
j = 0
for i in range(length):
if e==0:
continue
elif a%e==0:
j +=1
else:
break
if j==length:
yield a
a=fib()
for i in range(10):
print(next(a))
chongchuigu
发表于 2018-9-12 11:59:32
def a207(n):
a=5
b=8
while n:
c=a+b
s3=str(c)
if '0' in s3:
s3=s3.replace('0','')
if '1' in s3:
s3=s3.replace('1','')
s2=list(set(()))
if 6 in s2:
try:
s2.remove(3)
s2.remove(2)
except ValueError:
pass
if 8 in s2:
try:
s2.remove(4)
s2.remove(2)
except ValueError:
pass
if 9 in s2:
try:
s2.remove(3)
except ValueError:
pass
if 4 in s2:
try:
s2.remove(2)
except ValueError:
pass
count=0
for i in s2:
if c%i:
count+=1
if count==0:
print(c)
n-=1
a=b
b=c
else:
a=b
b=c
count=0
a207(10)
学学看看
发表于 2018-9-12 11:59:34
FC的注册很坑
发表于 2018-9-12 13:47:38
本帖最后由 FC的注册很坑 于 2018-9-12 14:36 编辑
#再来个超长版本
def fib(n):
a=0
b=1
for i in range(n):
a,b=b,a+b
return b
def fun207(n):
st=str(n)
li=paixu(st)
a0=False
a1=False
a2=False
a3=False
a4=False
for i in li:
if i==0:
a0=True
if i==1:
a1=True
if i==4 or i==6 or i==8:
a2=True
if i==6 or i==9:
a3=True
if i==8:
a4=True
if a0==True:
li.remove(0)
if a1==True:
li.remove(1)
if a2==True:
try:
li.remove(2)
except:
pass
if a3==True:
try:
li.remove(3)
except:
pass
if a4==True:
try:
li.remove(4)
except:
pass
for i in li:
if n % i!=0:
return False
return True
def paixu(st):# 去重和由大到小排序
l=len(st)
a=[]
for i in range(l):
a.append(int(st))
a=list(set(a))
a.sort()
a.reverse()
return a
count=7
total=1
while total<=10:
a=fib(count)
count+=1
if fun207(a):
print(a)
total+=1先贴个初稿上来看看情况{:10_277:}def fib(n):
a=0
b=1
for i in range(n):
a,b=b,a+b
return b
def fun207(n):
st=str(n)
list=paixu(st)
for i in list:
if i!=0 and i!=1: # 不用除以0和1
if n % i!=0:
return False
return True
def paixu(st):
l=len(st)
a=[]
for i in range(l):
a.append(int(st))
a=list(set(a))
a.sort()
a.reverse()
return a
count=7
total=1
while total<=10:
a=fib(count)
count+=1
if fun207(a):
print(a,end=" ")
total+=1
apple_wt
发表于 2018-9-12 14:00:27
昨天的今天可以给看答案了吧!!!!
raphael213
发表于 2018-9-12 14:44:07
本帖最后由 raphael213 于 2018-9-12 16:06 编辑
a, b, i = 0, 1, 0
list = []
while(i < 10):
a, b = b, a+b
str_a = str(a)
str_a1 = ""
n = 0
if a >10:
#去重,和0
for x in str_a:
if int(x) != 0:
if x not in str_a1:
str_a1 += x
for each in str_a1:
if a % int(each) == 0:
n += 1
if n == len(str_a1):
list.append(a)
i += 1
for i in range(len(list)):
print(list)
wyp02033
发表于 2018-9-12 15:53:58
def fab():
a, b = 5, 8
while True:
a, b = b, a + b
yield b
def main():
num = fab()
count = 0
while count < 10:
next_num = next(num)
next_num_list = list(set())
if 1 in next_num_list:
next_num_list.remove(1)
if 0 in next_num_list:
next_num_list.remove(0)
primes =
next_num_list.sort(reverse=True)
new_next_num_list = next_num_list.copy()
for i in range(len(next_num_list)-1):
if next_num_list in primes:
continue
else:
for j in range(i+1, len(next_num_list)):
if next_num_list % next_num_list == 0 and next_num_list in new_next_num_list:
new_next_num_list.remove(next_num_list)
result_list = []
for each in new_next_num_list:
if next_num % each:
result_list.append(False)
else:
result_list.append(True)
if False not in result_list:
print(next_num)
count += 1
if __name__ == '__main__':
main()
ccqzhm
发表于 2018-9-12 15:55:38
本帖最后由 ccqzhm 于 2018-9-12 17:04 编辑
empty_set = set()
repeat_dict = {9:{3}, 8:{4,2}, 7:empty_set, 6:{3, 2}, 5:empty_set, 4:{2}, 3:empty_set, 2:empty_set}
def check(n):
if n < 10:
return False
number_set = set()
remov_set = set()
for x in number_set:
remov_set |= repeat_dict
number_set -= remov_set
# print(n, str(number_set))
for x in number_set:
if n % x != 0:
return False
return True
def fib():
a,b = 0,1
while True:
a, b = b, a + b
if check(b):
yield b
def fun207():
f = fib()
for i in range(10):
print(next(f))
fun207()
阿池
发表于 2018-9-12 15:56:22
{:10_316:}
塔利班
发表于 2018-9-12 20:30:20
天圆突破 发表于 2018-9-11 17:01
我觉得考虑效率的话,去重去01外加逆排序就足够了
如果为了去掉2,3,4(只能去这3个数字),需要遍历4次才能 ...
万一这个数恰好就是0,1组成的呢
黑白、
发表于 2018-9-12 20:36:09
def fun207(temp):
tempS = temp
while tempS:
num = tempS%10
tempS //= 10
if num == 0:
continue
elif temp%num == 0:
continue
else:
return 0
break
return 1
def fab(numMax):
each,a,b = 0,8,13
flag = 0
while each<numMax:
temp = b
flag = fun207(temp)
if flag == 1:
yield b
a,b = b,a+b
each += 1
else:
a,b = b,a+b
for each in fab(10):
print('-->',each)
冬雪雪冬
发表于 2018-9-12 21:08:11
塔利班 发表于 2018-9-12 20:30
万一这个数恰好就是0,1组成的呢
有道理,虽然没有碰到这样的数,但也应该考虑到。我在出题时没有想周全。
colinshi
发表于 2018-9-13 10:08:48
def func207(n, c):
#n表示需要输出的数字最小值屏蔽,屏蔽个位数,c表示需要多少个这样的数
tmp = []
for i in fab():
if n <= i:
tmplist=cushu(i)
if tmplist:
for a in tmplist:
if i % a != 0:
break
else:
tmp.append(i)
if len(tmp) >= c:
return tmp
def cushu(l):
tmplist = set()
for j in str(l):
if int(j) % 5 == 0:
tmplist.add(5)
if int(j) % 7 == 0:
tmplist.add(7)
if int(j) % 2 == 0:
tmplist.add(2)
if int(j) % 3 == 0:
tmplist.add(3)
if tmplist:
return tmplist
else:
return
def fab():
n, a, b = 0, 0, 1
while 1:
yield b
a, b = b, a + b
n = n + 1
import time
start = time.time()
print(func207(10, 10))
print(time.time()-start)
使用生成器的写法,yield的写法,不知道符不符合效率要求。