-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreferences.js
More file actions
70 lines (62 loc) · 2.27 KB
/
references.js
File metadata and controls
70 lines (62 loc) · 2.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
function in_line_x_pattern(x)
{
//x is the index of the line to be put to pattern
var rows_filled = dimensions("rows_filled");
rows_filled = rows_filled[x-1];
var max_column = dimensions("max_column");
//here we need to find out what kind of progression is happening
var progression = "";
var arithmetic_progression = false;
var geometric_progression = false;
var harmonic_progression = false;
//here we initialize the variables
var common_difference = 0;
var common_ratio = 0;
//here we define the relationship to one another
for(var i=1;i<(max_column-1);i++)//start from 1 to incorporate the zeroth element and we take upto one unit short for the last
{
if(table[x-1][i] == false)
{
console.log("We find a break in "+(i+1)+"th element");
continue;
}
var current_count = i;
var previous_count = i-1;
var next_count = i+1;
common_difference = current_count-previous_count;
common_ratio = current_count/previous_count;
//now we predict the next element in the progression
var predict_arithmetic = current_count+(i*common_difference);
var predict_geometric = current_count*Math.pow(common_ratio,i);
var predict_harmonic = 1/(current_count+(i*common_difference));
console.log("current element is "+current_count);
console.log("previous element is "+previous_count);
console.log("next count is "+next_count);
console.log("The common difference is "+common_difference);
console.log("The common ratio is "+common_ratio);
console.log("Arithmetic progression predicts "+predict_arithmetic);
console.log("Geometric progression predicts "+predict_geometric);
console.log("Harmonic progression predicts "+predict_harmonic);
//now we check which kind of progression was used
if(predict_arithmetic == next_count)
{
arithmetic_progression = true;
}
if(predict_geometric == next_count)
{
geometric_progression = true;
}
if(predict_harmonic == next_count)
{
harmonic_progression = true;
}
}
//now we allot a kind of progression
if(arithmetic_progression == true)
progression = "arithmetic";
if(geometric_progression == true)
progression = "geometric";
if(harmonic_progression == true)
progression = "harmonic";
console.log("The progression is "+progression);
}