Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Flux-Dragon
authored and
Flux-Dragon
committed
Jan 30, 2013
1 parent
ff5bbed
commit 189a2f1
Showing
5 changed files
with
442 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<script src="022.js"></script> | ||
<script type="text/javascript"> | ||
|
||
//"ABC".charCodeAt(0) // returns 65 | ||
namelist = namelist.sort(); | ||
|
||
var Totalsum = 0; | ||
|
||
function sumelement(element){ | ||
var sum =0; | ||
|
||
for( var i=0; i<element.length; i++){ | ||
|
||
sum += element.charCodeAt(i)-64; | ||
} | ||
return sum; | ||
} | ||
|
||
function traverseElements(){ | ||
|
||
for( var i=0; i<namelist.length; i++){ | ||
|
||
Totalsum += (i+1)*sumelement(namelist[i]); | ||
console.log(i+", "+Totalsum); | ||
} | ||
} | ||
|
||
traverseElements(); | ||
|
||
</script> | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<script type="text/javascript"> | ||
|
||
var Mynumber = function(){ | ||
this.num; | ||
this.sum; | ||
this.list = []; | ||
this.myanswer = 0; | ||
this.divsum = function (){ | ||
var max = Math.sqrt(this.num); | ||
var sum = 1; | ||
var i; | ||
for(i=2; i<=max; i++) | ||
{ | ||
if((this.num %i) == 0) | ||
{ | ||
sum += i; | ||
sum += this.num/i; | ||
} | ||
} | ||
if((i-1)==max) | ||
sum -=(i-1); | ||
this.sum = sum; | ||
}; | ||
|
||
this.checklist = function (){ | ||
var temp; | ||
|
||
for(var i=0; i<this.list.length; i++) | ||
{ | ||
temp = this.num - this.list[i]; | ||
//console.log(temp+"&&"+ this.list[i]); | ||
if( this.list.indexOf(temp) >= 0 ) | ||
{ | ||
//console.log("MAGIC!"); | ||
return false; | ||
} | ||
} | ||
|
||
return true; | ||
}; | ||
}; | ||
|
||
var num1 = new Mynumber(); | ||
var m = 1; | ||
for(var j=1; j<28124;j+=m) | ||
{ | ||
num1.num = j; | ||
// console.log("*%1234%*"+num1.list.length); | ||
num1.divsum(); | ||
if( num1.sum > j )//&& (num1.num %2 !=0) ) | ||
{ | ||
// console.log(j+" *is abundant* "+(num1.sum) ); | ||
num1.list.push( (num1.num) ); | ||
} | ||
// else | ||
// console.log(j+" *is abundant* "+num1.sum); | ||
} | ||
|
||
/*for(var j=0; j<num1.list.length; j++) | ||
{ | ||
console.log(j+"-list: "+num1.list[j]); | ||
}*/ | ||
|
||
for(var j=1; j<28124; j++) | ||
{ | ||
num1.num = j; | ||
if( num1.checklist() ) | ||
{ | ||
num1.myanswer += num1.num; | ||
console.log(num1.num + " " + num1.myanswer); | ||
} | ||
} | ||
|
||
console.log("Final Answer = " + num1.myanswer); | ||
|
||
/* | ||
223 | ||
233 | ||
225 | ||
2223 | ||
235 | ||
2233 | ||
2225 | ||
237 | ||
22223 | ||
2227 | ||
2235 | ||
2311 | ||
257 | ||
22233 | ||
2313 | ||
*/ | ||
|
||
</script> |
Oops, something went wrong.