math_magic 0.0.1 → 0.0.2

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/math_magic.rb +41 -0
  3. metadata +3 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90adedd3a721b3ea55330f9e2c629a59de044a9153892bef00afb68b7a3b3dbe
4
- data.tar.gz: 88fa16096b6466ddafc4ecce0a5c675c38cab810dd72a7da813493f8b5958076
3
+ metadata.gz: b5806ada55758a7e7af18ae6053d29391a113539f2829a597d5fc0e15d0c7f2c
4
+ data.tar.gz: 29e07820fa835804004ab7ac46177b7b738cac961018f2c1dce4bf544e63e465
5
5
  SHA512:
6
- metadata.gz: '09c480200fc4184528a4c60b05739efac2e1232766da2810edd3edbc770983365cc47c8ce40ee2dcf33d75ed5b807017aab57544aa3b0306206a7f2c6582e5bf'
7
- data.tar.gz: 722dd85f53e7d8dd4c8dbbd8b7cdec0093de92c6e3005404b4f7fbbc7a26310696674674244a49408b72637b10d781242e2783d47925a891ecf40efe8bff4976
6
+ metadata.gz: e678ad75a3c771b233d4479cdbd421809e0971ae75a902d7ee25d80fd759743fd1441abaac520445322236cae4a890c671bc5bf0e450fa499a145f9be4db2354
7
+ data.tar.gz: e7b363c765da51f66d60694432f1f539c841e49a92b4a73e8ec9247b449c4e6b6e4d52d37b634be0be39878589886e050aca7115bcdd2ad3ea4acff9105a995d
data/lib/math_magic.rb ADDED
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Description: A class that contains methods for performing mathematical
4
+ # operations.
5
+ class MathMagic
6
+ def self.gcd(num1, num2)
7
+ if num2.zero?
8
+ num1
9
+ else
10
+ gcd(num2, num1 % num2)
11
+ end
12
+ end
13
+
14
+ def self.prime?(num)
15
+ if num < 2
16
+ false
17
+ else
18
+ temp = 2
19
+ while (temp * temp) <= num
20
+ return false if (num % temp).zero?
21
+
22
+ temp += 1
23
+ end
24
+ true
25
+ end
26
+ end
27
+
28
+ def self.factors(num)
29
+ factors = []
30
+ temp = 2
31
+ while (temp * temp) <= num
32
+ if (num % temp).zero?
33
+ factors << temp
34
+ factors << num / temp
35
+ end
36
+ temp += 1
37
+ end
38
+
39
+ factors.sort
40
+ end
41
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: math_magic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sahil Bansal
@@ -15,7 +15,8 @@ email: shlbnsl843@gmail.com
15
15
  executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
18
- files: []
18
+ files:
19
+ - lib/math_magic.rb
19
20
  homepage:
20
21
  licenses: []
21
22
  metadata: {}