-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
71 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,3 +28,6 @@ | |
sum+=intMax | ||
|
||
print(sum) | ||
|
||
# what is the time complexity? | ||
# O(n) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import math | ||
|
||
|
||
realPartC = 0.01 | ||
|
||
imagPartC = -0.64 | ||
|
||
|
||
arrSeen = [] | ||
counter = 0 | ||
realPart = 0 | ||
imagPart = 0 | ||
def normal_round(num, ndigits=0): | ||
""" | ||
Rounds a float to the specified number of decimal places. | ||
num: the value to round | ||
ndigits: the number of digits to round to | ||
""" | ||
if ndigits == 0: | ||
return int(num + 0.5) | ||
else: | ||
digit_value = 10 ** ndigits | ||
return int(num * digit_value + 0.5) / digit_value | ||
while True: | ||
tempRealPart = realPart | ||
realPart = tempRealPart**2 - imagPart**2 | ||
imagPart = tempRealPart * imagPart *2 | ||
|
||
|
||
realPart = realPart + realPartC | ||
imagPart = imagPart + imagPartC | ||
|
||
realPart = normal_round(realPart,2) | ||
imagPart = normal_round(imagPart,2) | ||
|
||
arrSeen.append((realPart,imagPart)) | ||
absValue = math.sqrt(realPart**2 + imagPart**2) | ||
print(arrSeen) | ||
if absValue > 4: | ||
print("ESCAPES",counter+1) | ||
break | ||
elif arrSeen.count((realPart,imagPart)) ==2: | ||
print(realPart,imagPart) | ||
print(counter) | ||
break | ||
else: | ||
counter +=1 | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
fib= [1,2,3,5,8,13, | ||
21, 55, 89, 144,233,377,610 | ||
] | ||
|
||
for x in range(1,11): | ||
stop = 0 | ||
for y in range(0,13): | ||
if stop ==0 and fib[y] %x ==0: | ||
print(x) | ||
stop =1 | ||
|