Skip to content

old #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions isprime.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function isPrime(n) {

for (var i = 2; i <= Math.sqrt(n); i++) {
if (n % i == 0) {isPrime = false}
}

return isPrime;

}

console.log(isPrime(39))
17 changes: 17 additions & 0 deletions numSquare.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//Create a function called numSquare that will return
//an array of all perfect square numbers up to, but not exceeding a max number.

var maxNumber = 500;
var newArray = [];

var numSquare = function (maxNumber) {
for (var i = 0; i < maxNumber; i++) {
if (i * i < maxNumber) {
var x = i * i;
newArray.push(x);
}
}
return newArray;
}

console.log(numSquare(maxNumber));
23 changes: 23 additions & 0 deletions primes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
function isPrime(n) {

for (var i = 2; i <= Math.sqrt(n); i++) {
if (n % i === 0) {
return false;
}
}

return true;

};

function primes(maxNum) {
var newArray = [];
for (var i = 2; i <= maxNum; i+=1) {
if (isPrime(i) === true) {
newArray.push(i);
}
}
return newArray;
};

console.log(primes(100));
13 changes: 13 additions & 0 deletions sillySum.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//Write a function that takes an array of numbers, and returns the sum of each number multiplied by its index.

var array = [1,2,3,4,5];

var sillySum = function(j) {
var count = 0
for (i = 0; i < array.length; i++) {
count += (array[i] * i)
}
console.log(count);
}

sillySum(array);