@gobeljanovic/matematicki-modul 1.0.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.
Files changed (4) hide show
  1. package/README.md +13 -0
  2. package/main.js +49 -0
  3. package/package.json +22 -0
  4. package/test.js +11 -0
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # Kako instalirati Modul
2
+ ### ?
3
+
4
+
5
+ ## U ovom modulu imamo 7 matematckih izraza
6
+ - naKvadrat(broj) - vraca prosledjeni broj na kvadrat
7
+ - faktorijel(broj) - rekurzivna funkcija koja nam vraca faktorijel prosledjenog broja
8
+ - stepen(broj,stepen) - vraca stepenovani prosledjeni broj -> broj^stepen
9
+ - koren(broj) - vraca vrednost kvadratnog korena za prosledjeni broj
10
+ - ostatakPriDeljenju(broj1,broj2) - vraca ostatak pri deljenju dva prosledjena broja
11
+ - paranBroj(broj) - vraca TRUE ukoliko je broj paran, FALSE ukoliko je neparan
12
+ - neparanBroj(broj) - vraca FALSE ukoliko je broj paran, TRUE ukoliko je neparan
13
+
package/main.js ADDED
@@ -0,0 +1,49 @@
1
+ const math = require('mathjs');
2
+
3
+
4
+ const naKvadrat = (num) => {
5
+ return math.multiply(num,num);
6
+ }
7
+ const faktorijel = (num) =>{
8
+ if(num<0){
9
+ return 'Faktorijel negativnog broja ne postoji!';
10
+ }
11
+ else if(num === 1 || num === 0){
12
+ return num;
13
+ }
14
+ else{
15
+ return num * faktorijel(num-1);
16
+ }
17
+ }
18
+
19
+ const stepen = (num,stepen) => {
20
+ return math.pow(num,stepen);
21
+ }
22
+
23
+ const koren = (num) =>{
24
+ if(num<0){
25
+ return "Koren ne moze od negativnog broja";
26
+ }else{
27
+ return math.sqrt(num);
28
+ }
29
+ }
30
+ const ostatakPriDeljenju=(a,b)=>{
31
+ return a % b;
32
+ }
33
+ const paranBroj=(num)=>{
34
+ return (num % 2 === 0);
35
+ }
36
+ const neparanBroj=(num)=>{
37
+ return (num % 2 !== 0);
38
+ }
39
+
40
+
41
+ module.exports = {
42
+ naKvadrat,
43
+ faktorijel,
44
+ stepen,
45
+ koren,
46
+ ostatakPriDeljenju,
47
+ paranBroj,
48
+ neparanBroj
49
+ }
package/package.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "@gobeljanovic/matematicki-modul",
3
+ "version": "1.0.0",
4
+ "description": "IST domaci node paket",
5
+ "license": "ISC",
6
+ "author": "Djordje Gobeljic NRT-40/23",
7
+ "type": "commonjs",
8
+ "main": "main.js",
9
+ "scripts": {
10
+ "test": "test.js"
11
+ },
12
+ "dependencies": {
13
+ "mathjs": "^15.2.0"
14
+ },
15
+ "keywords": [
16
+ "math",
17
+ "node",
18
+ "faktorijel",
19
+ "koren",
20
+ "stepen"
21
+ ]
22
+ }
package/test.js ADDED
@@ -0,0 +1,11 @@
1
+ const matematika = require("./main.js")
2
+
3
+ console.log(`7 na kvadrat = ${matematika.naKvadrat(7)}`)
4
+ console.log(`koren od 16 = ${matematika.koren(16)}`)
5
+ console.log(`ostatak pri deljenju 9 sa 2 = ${matematika.ostatakPriDeljenju(9,2)}`)
6
+ console.log(`faktorijel od 5 = ${matematika.faktorijel(5)}`)
7
+ console.log(`2 na 3 = ${matematika.stepen(2,3)}`)
8
+ console.log(`4 je paran ? = ${matematika.paranBroj(4)}`)
9
+ console.log(`4 je neparan ? = ${matematika.neparanBroj(4)}`)
10
+ console.log(`5 je paran ? = ${matematika.paranBroj(5)}`)
11
+ console.log(`5 je neparan ? = ${matematika.neparanBroj(5)}`)