예제 #1
0
from problems_01_25.problem_05 import natural_num_division_streak
from problems_01_25.plots.useful import array_from_function
import matplotlib.pyplot as plt
import numpy as np

#trying numbers over 18 takes a long time!
x = np.arange(1,15)
y = array_from_function(x, natural_num_division_streak)

plt.plot(x, y, '-')

#plot follows a linear pattern when y is log-scaled
plt.yscale('log')


plt.xlabel('Streak of N-natural numbers required')
plt.ylabel('Smallert number that is perfectly divisible')
plt.show()


예제 #2
0
from problems_01_25.problem_02 import even_fibsum
from problems_01_25.plots.useful import array_from_function
import matplotlib.pyplot as plt
import numpy as np

# plot the sum of even integers in a 
# Fibbonicci series where the largest
# term is less than the limit below
LIMIT = 10000

x = np.arange(0,LIMIT)
y = array_from_function(x, even_fibsum)

plt.xlabel('Largest term in Fib. Series')
plt.ylabel('Sum of terms')
plt.title(
    """
    Sum of even terms in a Fibonacci series
    """
)
plt.plot(x,y, '-')

# this graph looks great in a log-log scale!
plt.xscale('log')
plt.yscale('log')
plt.show()
예제 #3
0
from problems_01_25.problem_03 import largest_prime_factor
from problems_01_25.plots.useful import array_from_function
import matplotlib.pyplot as plt
import numpy as np

# plot the largest prime factor for each integer
# less than the limit
LIMIT = 10000

x = np.arange(0,LIMIT)
y = array_from_function(x, largest_prime_factor)

plt.xlabel('Integer')
plt.ylabel('Largest Prime Divisor')
plt.title(
    """
    Largest Prime Divisor of Integers Less Than %s
    """% LIMIT)
    
plt.plot(x,y, ',')
plt.show()