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
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
<meta http-equiv="Content-Script-Type" content="text/javascript"> | |
<title>素数の時だけJOJO!</title> | |
<script type="text/javascript"> | |
for(var i = 1; i <= 100; i++){ | |
var c = 0;//カウンタを初期化 | |
var p = 1;//素数フラグを立てる | |
for(var j = 1; j <= i; j++){ |
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
<html> | |
<head> | |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | |
<meta http-equiv="Content-Script-Type" content="text/javascript"> | |
<title>素数の時だけJOJO!(エラトステネスの篩版)</title> | |
<script type="text/javascript" src="e:\works\prototype.js"></script> | |
<script type="text/javascript"> | |
function createprimearray(x){ | |
var primearray = new Array();//素数配列 | |
var searcharray = new Array();//検索配列 |
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
//素数の時だけjojo(エラトステネスの篩) | |
//K.A | |
import scala.math._ | |
object prime { | |
def prime(acl : List[Int], sl : List[Int], ms : Int) : List[Int] = sl match { | |
case Nil => acl.reverse ::: sl | |
case sl => { | |
if (sl.head != 2 && (sl.isEmpty || pow(ms, 2) > sl.last)) acl.reverse ::: sl |
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
object qksort { | |
def qksort(sl: List[Int]): List[Int] = { | |
sl match { | |
case List() => sl | |
case slh::sll => qksort(sll.filter(slh > _)) ::: List(slh) ::: qksort(sll.filter(slh < _)) | |
} | |
} | |
def main(args: Array[String]) { | |
val ls = List(5, 27, 15, 31, 13, 23, 49, 16, 53, 39, 24, 11, 21, 63, 87) | |
qksort(ls).foreach{println} |
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
import java.io._ | |
object filesearch { | |
def filesearch(path : String, schwds : String){ | |
try{ | |
new File(path).listFiles.map{ | |
case d if d.isDirectory() => filesearch(d.getPath(), schwds) | |
case f if f.isFile() && f.getName().contains(schwds) => println(f.getPath()) | |
case e => e | |
} |
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
import java.io._ | |
import scala.io.Source | |
object fileinsearch { | |
def fileinsearch(path : String, schwds : String, schext : String){ | |
try{ | |
new File(path).listFiles.map{ | |
case d if d.isDirectory() => fileinsearch(d.getPath(), schwds, schext) | |
case f if f.isFile() && f.canRead() && f.getName().endsWith(schext) => { |
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
import scala.math._ | |
object healthparameter { | |
def healthparameter(name : String, years : Int, sex : String, height : Double, weight : Double) : List[String] = { | |
lazy val heightm = if (height > 3.0) (height / 100.0) else height | |
val bmi = weight / pow(heightm, 2) | |
val sbw = pow(heightm, 2) * 22 | |
val rohrerindex = weight / pow(height, 3) * 10000000 | |
lazy val bmr = if (!sex.contains("f")) (13.397 * height) + (4.799 * height) - (5.677 * years) + 88.362 |
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
import scala.math._ | |
object writtenOracle { | |
def intCalcD(d : Double)(r : Double) : Int = floor((d + 1) * r).toInt | |
val destinyp = intCalcD(_:Double)(random) | |
def writtenOracle(name : String) : String = { | |
val destinypoint = destinyp(100) | |
destinypoint match { |
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
//http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%2020 | |
//K.A | |
object problem20 { | |
def sum(acl : Int, xs : List[String]) : Int = xs match { | |
case Nil => acl | |
case y :: ys => sum(acl + y.toInt, ys) | |
} | |
def problem20(is : Int) : Int ={ | |
sum(0,(BigInt(1) to is).reverse.product.toString.split("").filter(_ != "").toList) |
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
//http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%2021 | |
//K.A | |
object problem21 { | |
def calcAmicable(acl : Int, xs : List[Int]) : Int = xs match { | |
case Nil => acl | |
case y :: ys => { | |
val divisora = (Range(1,y + 1).toList.filter(y % _ == 0).sum - y) | |
calcAmicable(acl + (if (Range(1, divisora + 1).toList.filter(divisora % _ == 0).sum - divisora == y && divisora != y) divisora else 0), ys) | |
} |
OlderNewer