Sha256: 2f1da358b3fd31943ad0442336cc2ff20196e151d5a7092b1f61f31924644542

Contents?: true

Size: 882 Bytes

Versions: 1

Compression:

Stored size: 882 Bytes

Contents

require "ttanaka_2016_gem/version"

module Ttanaka2016Gem
  class Main 
    # display "Hello"
    def say_Hello
      print 'Hello'
    end

    # calculate GCD
    def calc_GCD(num1, num2)
      if num1 < num2
	temp = num1
	num1 = num2
	num2 = temp
      end

      while num2 > 0
	r = num1 % num2
	num1 = num2
	num2 = r
      end

      return num1
    end

    # calculate LCM
    def calc_LCM(num1, num2)
      num1 * num2 / calc_GCD(num1, num2)
    end

    def prime(n)
      if n <= 1
        return false
      end
      num = 2
      n.times do
        if ((n % num) == 0 && (n != num))
          return false
        end
        num = num + 1
      end
      return true
    end

    def get_prime_list(n)
      ret = Array.new
      n = n + 1
      n.times do |i|
        if prime(i) == true
          ret.push(i)
        end
      end
      return ret
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ttanaka_2016_gem-0.1.0 lib/ttanaka_2016_gem.rb