PY-Into 5
getopt
getopt is a library for utilizing command line options. By adding arguments we can extend simple static variables.
As we have worked with Pythagorean expression, all the variables have been static in nature now with we can make a utility that that will take any combination of numbers.
Using the example code make a program that you can run from the command line, and test it.
fizzbuzz?
We are going to use the fizzbuzz as an entry point for the first Euler problem.
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9.The sum of these multiples is 23.Find the sum of all the multiples of 3 or 5 below 1000.
Going back to the modulo examples, we now add these to an if statement.
elm = 10
if elm%3 == 0:
print("elm has no remainder")
Right this is pretty straight forward, maybe? Now lets replace elm's static number with for loop and cycle through some numbers
for elm in range(100):
if elm%3 == 0:
print("elm has no remainder")
This loop will print all mod 3 results, but the question is geared toward multple 3 and 5.
for elm in range(100):
if elm%3 == 0 and elm%5 == 0;
print("elm has no remainder")
With a compound conditional we can begin to see how you might solve the whole fizzbuzz issue.
As an example of the same algorithm being used across different languages look at my fizzbuzz page
Also if you want to fork my code or add to it on GitHub go forth and do great things