Created
February 23, 2012 22:50
-
-
Save ddk50/1895542 to your computer and use it in GitHub Desktop.
Noob Code
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 'bayesdebug.rb' | |
class Eratosthenes20 | |
def self.isMultiple2(i) | |
## if i == 3 | |
if i == 3 | |
return false | |
end | |
if i % 2 == 0 | |
return true | |
else | |
return false | |
end | |
end | |
def self.isMultiple3(i) | |
if i == 3 | |
return false | |
end | |
if i % 3 == 0 | |
return true | |
else | |
return false | |
end | |
end | |
def self.isMultiple5(i) | |
if i == 5 | |
return false | |
end | |
if i % 5 == 0 | |
return true | |
else | |
return false | |
end | |
end | |
def self.checkPrime20(num) | |
if num > 20 | |
p "Not support" | |
else | |
prime = false | |
prime |= isMultiple2(num) | |
prime |= isMultiple3(num) | |
prime |= isMultiple5(num) | |
if prime | |
p "NoPrime" | |
else | |
p "Prime" | |
end | |
end | |
end | |
end | |
Bayse.passing_case_match(3) | |
Bayse.failing_case_match(2) | |
Bayse.guess {|i| | |
Eratosthenes20.checkPrime20(i) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
"Prime"
"NoPrime"
"./test.rb:43 -- 0.0"
"./test.rb:35 -- 0.0"
"./test.rb:31 -- 0.0"
"./test.rb:11 -- 0.1931471805599453"
"./test.rb:23 -- 0.1931471805599453"
"./test.rb:19 -- 1.0"
"./test.rb:7 -- 1.0"
"./test.rb:52 -- 1.0"