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
print("Prime numbers under 100:") | |
def is_prime(number): | |
divisor = 2 # Start with most likely factor and increment | |
while divisor <= (number / 2): | |
if ((number % divisor) == 0): return False | |
divisor += 1 | |
return True |
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
print("Gimme an integer and I’ll tell you if it’s prime:") | |
number = int(input()) | |
def is_prime(number): | |
divisor = 2 # Start with most likely factor and increment | |
while divisor <= (number / 2): | |
if ((number % divisor) == 0): return False | |
divisor += 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
require 'test/unit' | |
# Note: Encrypted strings used to validate the tests below code were generated at: | |
# http://www.braingle.com/brainteasers/codes/caesar.php | |
# So if the tests pass, they either validate my code or we both have the same bugs :) | |
class CaesarCipherTest < Test::Unit::TestCase | |
QUICK_BROWN_FOX = "the quick brown fox jumps over the lazy dog" | |
QUICK_BROWN_FOX_SHIFT_3 = "wkh txlfn eurzq ira mxpsv ryhu wkh odcb grj" | |
DEAR_BRUTUS = "The fault, dear Brutus, lies not in our stars but in ourselves." | |