Prior made a number of related spark related learning today, learning the language at Scala, Scala is a programming language, learning the Scala language learning helps to spark big data processing, while learning the complete eclipse of Scala's environment to build, and write a simple second experiment, a small part is to write a simple algorithm, the program useless for a long time, mainly built environment I spent a very long time.
Source
package ch.Tutorial2
object exercise2_1 {
def main(args:Array[String]){
print("请输入q的值:")
var p= scala.io.StdIn.readLine()
var Sn:Double=jisuan(p.toInt)
println("Sn="+Sn)
}
def jisuan(p:Int): Double={
var Sn:Double=0;
var i:Double=1;
while(Sn<p){
Sn+=(i+1)/i
i+=1
}
return Sn
}
}
Tomorrow will complete the program of Scala class method.