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
package proj_euler | |
object Problem9 { | |
def solve() : Long = { | |
var b = Range(1,500) | |
var c = 3 | |
for (i <- b){ | |
var a = (500000 - (1000 * i))/(1000-i) |
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
package proj_euler | |
object Problem8 { | |
lazy val num = "7316717653133062491922511967442" + | |
"6574742355349194934969835203127" + | |
"7450632623957831801698480186947" + | |
"8851843858615607891129494954595" + | |
"0173795833195285320880551112540" + | |
"6987471585238630507156932909632" + |
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
package proj_euler | |
object Problem7 { | |
def solve() : Int = { | |
var n = 2 | |
var i = 1 | |
while (true){ | |
if (is_prime(n) == true) | |
{ | |
i = i + 1 |
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
package proj_euler | |
object Problem6 { | |
def solve(): Int = { | |
var r1 = Range(1, 100) | |
var sum1 = r1.foldLeft(0)((x,y) => x + y*y) | |
var sum2 = r1.sum * r1.sum | |
return sum2 - sum1 | |
} |
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
package proj_euler | |
/* | |
* If we list all the natural numbers below 10 that are multiples of 3 or 5, | |
* we get 3, 5, 6 and 9. The sum of these multiples is 23. | |
* Find the sum of all the multiples of 3 or 5 below 1000. | |
*/ | |
/* | |
* |
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
package Problem2 | |
import scala.collection.mutable.Seq | |
/* | |
* Each new term in the Fibonacci sequence is generated | |
* by adding the previous two terms. | |
* By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... | |
* By considering the terms in the Fibonacci sequence whose values do not exceed | |
* four million, find the sum of the even-valued terms. |
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
package proj_euler | |
/* | |
* The prime factors of 13195 are 5, 7, 13 and 29. | |
* What is the largest prime factor of the number 600851475143 ? | |
*/ | |
object Problem3 { | |
def solve3(num1 : Long) : Long = { |
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
package proj_euler | |
/* | |
* A palindromic number reads the same both ways. | |
* The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 99. | |
* | |
* Find the largest palindrome made from the product of two 3-digit numbers. | |
*/ | |
//906609 |
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
package proj_euler | |
object Problem5 { | |
def solve() : Int ={ | |
val r1 = Range(1, 21).toList | |
var n = 20 | |
while (true){ | |
val mod = r1.forall(num => (n % num) == 0) | |
mod 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
(setq load-path (cons "/usr/local/lib/erlang/lib/tools-2.6.6.5/emacs" | |
load-path)) | |
(setq exec-path (cons "/usr/local/lib/erlang/bin" exec-path)) | |
(add-to-list 'auto-mode-alist '("\\.erl?$" . erlang-mode)) | |
(add-to-list 'auto-mode-alist '("\\.hrl?$" . erlang-mode)) | |
(setq erlang-root-dir "/usr/local/lib/erlang/") | |
(add-to-list 'exec-path "/usr/local/lib/erlang/bin") |