Last active
April 16, 2017 12:00
-
-
Save dj-marko/4ad0a4ff102cad918c3b58dab535897a to your computer and use it in GitHub Desktop.
Resenje zadatka
This file contains hidden or 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
var n,i; | |
for(n=100,i=0;i<n;){ | |
console.log( ((++i%3? '' : 'Dev') + (i%5? '' : 'Ops')) || i ); | |
} |
This file contains hidden or 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
function f(n) { | |
if(n==0) return 1; | |
return n*f(n-1); | |
} | |
console.log(f(5)); |
This file contains hidden or 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
function isPrime(num) { | |
for(var i = 2; i < num; i++) { | |
if(num % i === 0) return false; | |
} | |
return num !== 1; | |
} | |
console.log(isPrime(73) ? 'Prime' : 'Composite'); |
This file contains hidden or 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
var foo = [1, 2, 3, 5, 7]; | |
var bar = [1, 4, 6, 7, 8,7]; | |
function mergeArrays(arr1,arr2) { | |
var output = arr1.concat(arr2.filter(function (item) { | |
return arr1.indexOf(item) == -1; | |
})); | |
return output.sort(function(a, b){return a-b}); | |
} | |
console.log(mergeArrays(foo,bar)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment