my1201 What's a Sequence?

3012 days ago by MATH4R2012

#1) a(n)=(n-1)/n;show(a(n)) 
       
print "n\ta(n)" for n in range(1,6,1): print n,"\t",a(n).n() 
       
n	a(n)
1 	0.000000000000000
2 	0.500000000000000
3 	0.666666666666667
4 	0.750000000000000
5 	0.800000000000000
n	a(n)
1 	0.000000000000000
2 	0.500000000000000
3 	0.666666666666667
4 	0.750000000000000
5 	0.800000000000000
sum([a(n) for n in range(1,6,1)]).n() 
       
#2) b(n)=(-1)^(n+1)*2/n;show(b(n)) 
       
[b(n) for n in range(1,6,1)] 
       
sum([b(n) for n in range(1,6,1)]).n() 
       
#3) c(n)=e^n/n;show(c(n)) 
       
[c(n) for n in range(1,6,1)] 
       
#4) d(n)=(1/3)^n;show(d(n)) 
       
[d(n) for n in range(5)] 
       
sum([d(n) for n in range(5)]).n() 
       
#5) show([2^n for n in range(5)]) show([2*n for n in range(5)]) 
       

#6) def fact(n): if(n==0): return 1 else: return n*fact(n-1) print "n\tfact(n)" for n in range(50): print n,"\t", fact(n) 
       
n	fact(n)
0 	1
1 	1
2 	2
3 	6
4 	24
5 	120
6 	720
7 	5040
8 	40320
9 	362880
10 	3628800
11 	39916800
12 	479001600
13 	6227020800
14 	87178291200
15 	1307674368000
16 	20922789888000
17 	355687428096000
18 	6402373705728000
19 	121645100408832000
20 	2432902008176640000
21 	51090942171709440000
22 	1124000727777607680000
23 	25852016738884976640000
24 	620448401733239439360000
25 	15511210043330985984000000
26 	403291461126605635584000000
27 	10888869450418352160768000000
28 	304888344611713860501504000000
29 	8841761993739701954543616000000
30 	265252859812191058636308480000000
31 	8222838654177922817725562880000000
32 	263130836933693530167218012160000000
33 	8683317618811886495518194401280000000
34 	295232799039604140847618609643520000000
35 	10333147966386144929666651337523200000000
36 	371993326789901217467999448150835200000000
37 	13763753091226345046315979581580902400000000
38 	523022617466601111760007224100074291200000000
39 	20397882081197443358640281739902897356800000000
40 	815915283247897734345611269596115894272000000000
41 	33452526613163807108170062053440751665152000000000
42 	1405006117752879898543142606244511569936384000000000
43 	60415263063373835637355132068513997507264512000000000
44 	2658271574788448768043625811014615890319638528000000000
45 	119622220865480194561963161495657715064383733760000000000
46 	5502622159812088949850305428800254892961651752960000000000
47 	258623241511168180642964355153611979969197632389120000000000
48 	12413915592536072670862289047373375038521486354677760000000000
49 	608281864034267560872252163321295376887552831379210240000000000
n	fact(n)
0 	1
1 	1
2 	2
3 	6
4 	24
5 	120
6 	720
7 	5040
8 	40320
9 	362880
10 	3628800
11 	39916800
12 	479001600
13 	6227020800
14 	87178291200
15 	1307674368000
16 	20922789888000
17 	355687428096000
18 	6402373705728000
19 	121645100408832000
20 	2432902008176640000
21 	51090942171709440000
22 	1124000727777607680000
23 	25852016738884976640000
24 	620448401733239439360000
25 	15511210043330985984000000
26 	403291461126605635584000000
27 	10888869450418352160768000000
28 	304888344611713860501504000000
29 	8841761993739701954543616000000
30 	265252859812191058636308480000000
31 	8222838654177922817725562880000000
32 	263130836933693530167218012160000000
33 	8683317618811886495518194401280000000
34 	295232799039604140847618609643520000000
35 	10333147966386144929666651337523200000000
36 	371993326789901217467999448150835200000000
37 	13763753091226345046315979581580902400000000
38 	523022617466601111760007224100074291200000000
39 	20397882081197443358640281739902897356800000000
40 	815915283247897734345611269596115894272000000000
41 	33452526613163807108170062053440751665152000000000
42 	1405006117752879898543142606244511569936384000000000
43 	60415263063373835637355132068513997507264512000000000
44 	2658271574788448768043625811014615890319638528000000000
45 	119622220865480194561963161495657715064383733760000000000
46 	5502622159812088949850305428800254892961651752960000000000
47 	258623241511168180642964355153611979969197632389120000000000
48 	12413915592536072670862289047373375038521486354677760000000000
49 	608281864034267560872252163321295376887552831379210240000000000
#7) def fib(n): if(n==1 or n==2): return 1 else: return fib(n-1)+fib(n-2) [fib(n) for n in range(1,20,1)] 
       
#8) sum([1/k for k in range(1,4,1)]) 
       
#9) sum([fact(n) for n in range(4)]) 
       
#p821(7) [2^n/(3^n+1) for n in range(5)] 
       
#p821(29) def mystery(n): if(n==1): return 1 elif(n==2): return 2 elif(n>2): return mystery(n-1)*mystery(n-2) [mystery(n) for n in range(1,6,1)] 
       
#p821(49) sum([k^2/2 for k in range(1,6,1)]) 
       
#extra def drug(day): if(day==1): return 35 else: return .75*drug(day-1)+35 for day in range(1,100,1): print day,"\t",drug(day) 
       
1 	35
2 	61.2500000000000
3 	80.9375000000000
4 	95.7031250000000
5 	106.777343750000
6 	115.083007812500
7 	121.312255859375
8 	125.984191894531
9 	129.488143920898
10 	132.116107940674
11 	134.087080955505
12 	135.565310716629
13 	136.673983037472
14 	137.505487278104
15 	138.129115458578
16 	138.596836593933
17 	138.947627445450
18 	139.210720584088
19 	139.408040438066
20 	139.556030328549
21 	139.667022746412
22 	139.750267059809
23 	139.812700294857
24 	139.859525221143
25 	139.894643915857
26 	139.920982936893
27 	139.940737202669
28 	139.955552902002
29 	139.966664676502
30 	139.974998507376
31 	139.981248880532
32 	139.985936660399
33 	139.989452495299
34 	139.992089371474
35 	139.994067028606
36 	139.995550271454
37 	139.996662703591
38 	139.997497027693
39 	139.998122770770
40 	139.998592078077
41 	139.998944058558
42 	139.999208043919
43 	139.999406032939
44 	139.999554524704
45 	139.999665893528
46 	139.999749420146
47 	139.999812065110
48 	139.999859048832
49 	139.999894286624
50 	139.999920714968
51 	139.999940536226
52 	139.999955402170
53 	139.999966551627
54 	139.999974913720
55 	139.999981185290
56 	139.999985888968
57 	139.999989416726
58 	139.999992062544
59 	139.999994046908
60 	139.999995535181
61 	139.999996651386
62 	139.999997488539
63 	139.999998116405
64 	139.999998587303
65 	139.999998940478
66 	139.999999205358
67 	139.999999404019
68 	139.999999553014
69 	139.999999664760
70 	139.999999748570
71 	139.999999811428
72 	139.999999858571
73 	139.999999893928
74 	139.999999920446
75 	139.999999940335
76 	139.999999955251
77 	139.999999966438
78 	139.999999974829
79 	139.999999981122
80 	139.999999985841
81 	139.999999989381
82 	139.999999992036
83 	139.999999994027
84 	139.999999995520
85 	139.999999996640
86 	139.999999997480
87 	139.999999998110
88 	139.999999998582
89 	139.999999998937
90 	139.999999999203
91 	139.999999999402
92 	139.999999999552
93 	139.999999999664
94 	139.999999999748
95 	139.999999999811
96 	139.999999999858
97 	139.999999999894
98 	139.999999999920
99 	139.999999999940
1 	35
2 	61.2500000000000
3 	80.9375000000000
4 	95.7031250000000
5 	106.777343750000
6 	115.083007812500
7 	121.312255859375
8 	125.984191894531
9 	129.488143920898
10 	132.116107940674
11 	134.087080955505
12 	135.565310716629
13 	136.673983037472
14 	137.505487278104
15 	138.129115458578
16 	138.596836593933
17 	138.947627445450
18 	139.210720584088
19 	139.408040438066
20 	139.556030328549
21 	139.667022746412
22 	139.750267059809
23 	139.812700294857
24 	139.859525221143
25 	139.894643915857
26 	139.920982936893
27 	139.940737202669
28 	139.955552902002
29 	139.966664676502
30 	139.974998507376
31 	139.981248880532
32 	139.985936660399
33 	139.989452495299
34 	139.992089371474
35 	139.994067028606
36 	139.995550271454
37 	139.996662703591
38 	139.997497027693
39 	139.998122770770
40 	139.998592078077
41 	139.998944058558
42 	139.999208043919
43 	139.999406032939
44 	139.999554524704
45 	139.999665893528
46 	139.999749420146
47 	139.999812065110
48 	139.999859048832
49 	139.999894286624
50 	139.999920714968
51 	139.999940536226
52 	139.999955402170
53 	139.999966551627
54 	139.999974913720
55 	139.999981185290
56 	139.999985888968
57 	139.999989416726
58 	139.999992062544
59 	139.999994046908
60 	139.999995535181
61 	139.999996651386
62 	139.999997488539
63 	139.999998116405
64 	139.999998587303
65 	139.999998940478
66 	139.999999205358
67 	139.999999404019
68 	139.999999553014
69 	139.999999664760
70 	139.999999748570
71 	139.999999811428
72 	139.999999858571
73 	139.999999893928
74 	139.999999920446
75 	139.999999940335
76 	139.999999955251
77 	139.999999966438
78 	139.999999974829
79 	139.999999981122
80 	139.999999985841
81 	139.999999989381
82 	139.999999992036
83 	139.999999994027
84 	139.999999995520
85 	139.999999996640
86 	139.999999997480
87 	139.999999998110
88 	139.999999998582
89 	139.999999998937
90 	139.999999999203
91 	139.999999999402
92 	139.999999999552
93 	139.999999999664
94 	139.999999999748
95 	139.999999999811
96 	139.999999999858
97 	139.999999999894
98 	139.999999999920
99 	139.999999999940