This file contains hidden or 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
| def isPrime(n) | |
| factors = [] | |
| (2..n-1).each do |x| | |
| if (n % x == 0) | |
| return false | |
| end | |
| end | |
| factors << n | |
| puts factors | |
| end |
This file contains hidden or 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
| current = 1 | |
| previous = 0 | |
| sum = 0 | |
| new = 0 | |
| while new <= 4000000 do | |
| new = current + previous | |
| if (new % 2 == 0) | |
| sum += new | |
| end |
This file contains hidden or 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
| x = 0 | |
| y = 0 | |
| while x < 1000 do | |
| if ((x % 3 == 0) || (x % 5 == 0)) | |
| y += x | |
| end | |
| x = x + 1 | |
| end |
NewerOlder