I have been programming in java and new to scala . was trying my hands on some basic scala tutorials.I use eclipse Juno 4.2 with plugin for scala language. The JDK installed on the machine is 1.7.
the code below is for calculating sum of even fibonacci series below 4 million. when I run the code, the eclipse does not show any result and I am forced to terminate the process
var (a,b) = (1,2)
var sum = 0
while(a < 4000000)
{
if(a % 2 == 0)
{ sum += a
val swap = a
a = b
b= swap + b}
}
println(sum)
on the other hand when I change the default value of variable a to 2 that is
var (a,b) = (2,2)
the system compiles and runs to give this answer 1383447424
don't know why eclipse Juno does not compile the scala code, when the variable a uses the default value of 1. The JDK installed on the machine is JDK 1.7.
Will be very glad to have explanations