<jupyter_start><jupyter_text>Some Simple Numerical Programs<jupyter_code># Find the Cube Root of a Perfect Cube
# Return message if there is nothing.
x = int(input('Enter an integer: '))
ans = 0 # aka i
# The while loop achieves iteration.
while ans**3 < abs(x):
    print('Value of the decrementing function abs(x) - ans**3 is', abs(x) - ans**3)
    ans = ans + 1

# Ok now Ans is == Cube Root of x
# Orrrr it's greater than the cube root.
# ans**3 - abs(input) --> if it's 0, we have a cube root
# if it's Not 0 we don't have a cube root
if ans**3 != abs(x):
    print(x, "is not a perfect cube")
else:
    if x < 0:
        ans = -ans
    print('Cube root of', x, 'is', ans)

print('Final value of the decrementing function abs(x) - ans**3 is', abs(x) - ans**3)

# Apparantly the Decrementing fnction for the while loop is:
# abs(x) - ans**3

# abs(input) - (i**3)
# Since i starts @ 0, the first iteration of the decrementing function is always = abs(input)
# and it decreases from there as i increases.<jupyter_output>Enter an integer:  8<jupyter_text>When writing loops, you need to think about an appropriate **decrementing function**. Properties of Decrementing Functions:- It maps a set of program variables into an integer.- When the loop is entered, i's value is nonnegative.- When i's value is < 0, the loop terminates.- Its value is decreased over time throught the loop.**exhaustive enumeration** = a variant of guess and check in which all possibilities are enumerated until the right answer is achieved or the space of possibilities gets exhausted<jupyter_code># Start with an integer -> x
# Return root int and pwr int such that 1 < pwr < 6 
# and root**pwr is = x
# or print no pair of integers

x = int(input('Please Pick an Integer '))

x = 9
pwr = 2
root = 1
while pwr > 1 and pwr < 6:
    if root**pwr == x:
        print(f"{root}^{pwr} = {x}")
    else:
        root += 1
print("No combo found.")
    
# https://www.youtube.com/watch?v=i9zercRfE60&list=PLRJdqdXieSHN0U9AdnmwD-9QcR9hmw04d&index=3<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.111328125, 'fraction_numerical': 0.01708984375, 'mean_word_length': 3.7430555555555554, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 11, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '562284', 'license': 'MIT', 'n_tokens_mistral': 715, 'n_tokens_neox': 672, 'n_words': 284, 'path': 'chpt3/chpt3_reading.ipynb', 'repo_name': 'taylor-curran/6.0001-learn-computation', 'size': '2048'}