isPrime-mh 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 390fc1eded76eb3c83679cfa567225a61260d9024be56f9b2283920f52b916ab
4
+ data.tar.gz: '01915ae291342e3984c4e0dd75ffbbf9970661e8a9566e3922aa9acf885709b1'
5
+ SHA512:
6
+ metadata.gz: 3c69977387376a5b9de49a153d4f85cd6f46a782e9d944f8b1fb51a2bb6f9a5f67e56cd881d1f31c5efe82014fe6d9007299b9b5cf584e39d7e9cf48e8bf06de
7
+ data.tar.gz: bac08cd38dd5146d657e7798eabe550a51b0343ef5f780304fcf211968d03e7dfe0f6e3e2396c469568f102300ba5d28432ce92a6ff22974e596d96dd3f1ee1e
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in isPrime-mh.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # IsPrime::Mh
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/isPrime/mh`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Install the gem and add to the application's Gemfile by executing:
10
+
11
+ $ bundle add isPrime-mh
12
+
13
+ If bundler is not being used to manage dependencies, install the gem by executing:
14
+
15
+ $ gem install isPrime-mh
16
+
17
+ ## Usage
18
+
19
+ TODO: Write usage instructions here
20
+
21
+ ## Development
22
+
23
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
24
+
25
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
26
+
27
+ ## Contributing
28
+
29
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/isPrime-mh.
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/isPrime/mh/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "isPrime-mh"
7
+ spec.version = IsPrime::Mh::VERSION
8
+ spec.authors = ["Maxi Herrera"]
9
+ spec.email = ["herreramaxi@gmail.com"]
10
+
11
+ spec.summary = "Gem used to check if a number is a prime"
12
+ spec.description =" Simple prime checker"
13
+ spec.homepage = 'https://rubygems.org/gems/example'
14
+ spec.required_ruby_version = ">= 2.6.0"
15
+
16
+ # spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
17
+
18
+ # spec.metadata["homepage_uri"] = spec.homepage
19
+ # spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
20
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ spec.files = Dir.chdir(__dir__) do
25
+ `git ls-files -z`.split("\x0").reject do |f|
26
+ (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
27
+ end
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ # Uncomment to register a new dependency of your gem
34
+ # spec.add_dependency "example-gem", "~> 1.0"
35
+
36
+ # For more information and examples about making a new gem, check out our
37
+ # guide at: https://bundler.io/guides/creating_gem.html
38
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module IsPrime
4
+ module Mh
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
data/lib/isPrime/mh.rb ADDED
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "mh/version"
4
+
5
+ module IsPrime
6
+ # A prime number (or a prime) is a natural number greater than 1 that is not a product of two smaller natural numbers
7
+ # Prime definition from: https://en.wikipedia.org/wiki/Prime_number
8
+ def self.isPrime(num)
9
+ # if num is less or equal to 1, then return number is not prime
10
+ if num <=1 then
11
+ return "The number #{num} is not prime"
12
+ end
13
+
14
+ # if num is less or equal to 3, return is prime
15
+ if num <=3 then
16
+ return "The number #{num} is prime"
17
+ end
18
+
19
+ # for loop in range [2,num/2] to test if num is not prime
20
+ # num/2 is to improve the performance as there is no need to loop until num, it still is O(n).
21
+ for i in 2..num/2 do
22
+ # if num is evenly divisible by i, then num is not prime by definition
23
+ if num % i == 0 then
24
+ return "The number #{num} is not prime"
25
+ end
26
+ end
27
+
28
+ # we return 'is Prime' as num is not evenly divisible by any number between the range of [2,num/2]
29
+ return "The number #{num} is prime"
30
+ end
31
+ end
@@ -0,0 +1,6 @@
1
+ module IsPrime
2
+ module Mh
3
+ VERSION: String
4
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
5
+ end
6
+ end
metadata ADDED
@@ -0,0 +1,49 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: isPrime-mh
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Maxi Herrera
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-10-16 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: " Simple prime checker"
14
+ email:
15
+ - herreramaxi@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - Gemfile
21
+ - README.md
22
+ - Rakefile
23
+ - isPrime-mh.gemspec
24
+ - lib/isPrime/mh.rb
25
+ - lib/isPrime/mh/version.rb
26
+ - sig/isPrime/mh.rbs
27
+ homepage: https://rubygems.org/gems/example
28
+ licenses: []
29
+ metadata: {}
30
+ post_install_message:
31
+ rdoc_options: []
32
+ require_paths:
33
+ - lib
34
+ required_ruby_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: 2.6.0
39
+ required_rubygems_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ requirements: []
45
+ rubygems_version: 3.3.7
46
+ signing_key:
47
+ specification_version: 4
48
+ summary: Gem used to check if a number is a prime
49
+ test_files: []