File tree Expand file tree Collapse file tree 4 files changed +56
-0
lines changed
Expand file tree Collapse file tree 4 files changed +56
-0
lines changed Original file line number Diff line number Diff line change 1+ def collatz (x ):
2+ while x != 1 :
3+ print (x )
4+ if x % 2 == 0 :
5+ x = int (x / 2 )
6+ else :
7+ x = (3 * x ) + 1
8+ print (x )
Original file line number Diff line number Diff line change 1+ def exclamation (string ):
2+ for letter in string :
3+ if letter in 'AEIOUaeiou' :
4+ print (letter * 4 , end = '' )
5+ else :
6+ print (letter , end = '' )
7+ print ('!' )
Original file line number Diff line number Diff line change 1+ def approxPi (error ):
2+ divup = 4
3+ div = 1
4+ div1 = 1
5+ soma1 = 0
6+ soma2 = 0
7+ step = 1
8+ step1 = 1
9+ times = 1
10+ while soma1 - soma2 != error :
11+ for i in range (times - 1 ):
12+ if step1 % 2 == 0 :
13+ soma2 -= 4 / div1
14+ else :
15+ soma2 += 4 / div1
16+ div1 += 2
17+ step1 += 1
18+ for i in range (times ):
19+ if step % 2 == 0 :
20+ soma1 -= 4 / div
21+ else :
22+ soma1 += 4 / div
23+ div += 2
24+ step += 1
25+ times += 1
26+ div1 = 1
27+ div = 1
28+ step1 = 1
29+ step = 1
30+ if abs (soma1 - soma2 ) <= error :
31+ return soma1
32+ soma1 = 0
33+ soma2 = 0
Original file line number Diff line number Diff line change 1+ def poly (coefficients , x ):
2+ soma = 0
3+ for i in range (len (coefficients )):
4+ if i == 0 :
5+ soma += coefficients [i ]
6+ else :
7+ soma += coefficients [i ]* (x ** i )
8+ return soma
You can’t perform that action at this time.
0 commit comments