Skip to content

Instantly share code, notes, and snippets.

View sanket143's full-sized avatar
🏁
GOSH! Missed the finish again

Sanket sanket143

🏁
GOSH! Missed the finish again
View GitHub Profile
@sanket143
sanket143 / Factorial.js
Last active June 23, 2017 06:27
To calculate factorial
function factorialize(num) {
product=1;
var fast =[];
if(num>0){
var ghr= num;
for(i=1;i<=ghr;i++){
fast.push(i);
}
for(i=0;i<fast.length;i++){
product=product*fast[i];
@sanket143
sanket143 / Matrix(#3).js
Created May 29, 2017 06:51
To get determinant of 3*3 matrix
var matrix=[];
function Solve(matrix) {
var Det = matrix[0][0]*(matrix[1][1]*matrix[2][2] - matrix[1][2]*matrix[2][1])-matrix[0][1]*(matrix[1][0]*matrix[1][1]-matrix[1][2]*matrix[2][0])+matrix[0][2]*(matrix[1][0]*matrix[2][1]-matrix[1][1]*matrix[2][0]);
return Det;
}
Solve([[1,2,2],[3,4,5],[4,5,6]]);//Here goes your three cross three matrix;
@sanket143
sanket143 / Matrix(#2).js
Created May 29, 2017 05:42
To calculate determinant of 2*2 matrix
var matrix = [];
function Solve(matrix) {
var Det = matrix[0][0]*matrix[1][1] - matrix[0][1]*matrix[1][0];
return Det;
}
Solve([[1,2],
[3,4]]); // Here goes your matrix and you'll got you determinant;
@sanket143
sanket143 / Percentage.js
Created May 28, 2017 11:26
To calculate percentage
var marks = [];
var total = 0 ;
function Calculate(marks) {
for(i=0; i < marks.length ; i++) {
total = total + marks[i];
var percentage = total/marks.length ;
} return percentage;
}
Calculate([97,93,94]) ; // here comes your marks
// no matter the number of subjects, its Auto
@sanket143
sanket143 / magnitude of complex number.js
Last active October 18, 2021 11:54
To get magnitude of complex number(r) using javascript .
// complex number is usually in the form z = a + ib ;
//and here we are going to return the magnitude of this complex number by using Javascript ;
// As we know that, magnitude of complex number (r)= (a^2 + b^2)^1/2
var complex = [a,b];
var r = 0;
function valueR(complex) {
var rvalue = r + Math.pow(complex[0],2) + Math.pow(complex[1],2);
rvalue = Math.sqrt(rvalue);