Created
June 3, 2019 15:12
-
-
Save vajapravin/bd5b4fb957f33be834cd40c096f5ce34 to your computer and use it in GitHub Desktop.
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
class PrimeNumber | |
def initialize | |
print 'Enter number: ' | |
@num = gets.to_i | |
@primes = [] | |
end | |
def generate | |
for i in (2..(@num**2)) do | |
for j in (2..i) do | |
break if i%j == 0 | |
end | |
@primes << i if i.eql?(j) | |
break if @primes.length.eql?(@num) | |
end | |
end | |
def display | |
for i in (0..@num-1) do | |
for j in (0..@num-1) do | |
print "#{@primes[i]+@primes[j]} " | |
end | |
puts | |
end | |
end | |
end | |
p = PrimeNumber.new | |
p.generate | |
p.display |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment