Last active
June 10, 2019 23:03
-
-
Save daviinacio/5aecfaa16959676f387e3b02cddfe53a to your computer and use it in GitHub Desktop.
Math Gurl - Cinco curiosidades surpreendentes - Curiosidade 3; Algoritmo que encontra potências de 2 que não tem 0. https://www.onlinegdb.com/SkycOgrl4
This file contains hidden or 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
# Author: @daviinacio | |
# Date: 16/12/2018 | |
# Description: Algoritmo escrito com o objetivo de encontrar multiplos de 2 que não contenham 0 | |
num_base = 2 | |
num_wanted = 0 | |
range_min = 0 | |
range_max = 250 | |
show_while_check = False | |
result_array = [] | |
if input("Use default values (y/n): ") == 'n': | |
num_base = int(input('Type the base number: ')) | |
num_wanted = int(input('Type the wanted number: ')) | |
range_min = int(input('Type the min range: ')) | |
range_max = int(input('Type the max range: ')) | |
if input("Do you want to view the exponentials while checking? (y/n): ") == 'y': | |
show_while_check = True | |
if not show_while_check: | |
print("\nProcess started. Please wait..."); | |
for exponential in range(range_min, range_max): | |
# Calculate the exponential | |
num = num_base ** exponential | |
if show_while_check: | |
print("{}^{}: {}".format(num_base, exponential, num)) | |
# Check for zero | |
if not (str(num_wanted) in str(num)): | |
result_array.append("{}^{}: {}".format(num_base, exponential, num)) | |
print(); | |
print("Check finished - range = {} ~ {} ".format(range_min, range_max)) | |
print('\n\n') | |
print("## Exponentials without the number {} ##".format(num_wanted)) | |
for i in range(0, len(result_array)): | |
print(result_array[i]) | |
print('\n') | |
input("Press the <ENTER> key to continue...") | |
This file contains hidden or 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
Use default values (y/n): n | |
Type the base number: 2 | |
Type the wanted number: 0 | |
Type the min range: 0 | |
Type the max range: 100000 | |
Do you want to view the exponentials while checking? (y/n): n | |
Process started. Please wait... | |
Check finished - range = 0 ~ 100000 | |
## Exponentials without the number 0 ## | |
2^0: 1 | |
2^1: 2 | |
2^2: 4 | |
2^3: 8 | |
2^4: 16 | |
2^5: 32 | |
2^6: 64 | |
2^7: 128 | |
2^8: 256 | |
2^9: 512 | |
2^13: 8192 | |
2^14: 16384 | |
2^15: 32768 | |
2^16: 65536 | |
2^18: 262144 | |
2^19: 524288 | |
2^24: 16777216 | |
2^25: 33554432 | |
2^27: 134217728 | |
2^28: 268435456 | |
2^31: 2147483648 | |
2^32: 4294967296 | |
2^33: 8589934592 | |
2^34: 17179869184 | |
2^35: 34359738368 | |
2^36: 68719476736 | |
2^37: 137438953472 | |
2^39: 549755813888 | |
2^49: 562949953421312 | |
2^51: 2251799813685248 | |
2^67: 147573952589676412928 | |
2^72: 4722366482869645213696 | |
2^76: 75557863725914323419136 | |
2^77: 151115727451828646838272 | |
2^81: 2417851639229258349412352 | |
2^86: 77371252455336267181195264 | |
Press the <ENTER> key to continue... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment