Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import scala.math
- def isPrime(n:Int) : Boolean = {
- if (n <= 1) {
- return false
- }
- var index : Int = 0
- for (index <- 2 to math.sqrt(n).toInt) {
- if (n % index == 0) {
- return false
- }
- }
- return true
- }
- def isMersenne(p:Int) : Boolean = {
- var index : Int = 2;
- for (index <- 2 until p) {
- if (isPrime(index)) {
- if ((math.pow(2, index)-1).toInt == p) {
- return true
- }
- }
- }
- return false
- }
- def main(args: Array[String]) {
- var i : Int = 0
- for (i <- 1 to 100) {
- if (isMersenne(i) && isPrime(i)) {
- println(math.pow(i, 2).toInt)
- }
- else if (isPrime(i)) {
- println("AssFoot")
- }
- else if (i % 15 == 0) {
- println("FootAss")
- }
- else if (i % 3 == 0) {
- println("Foot")
- }
- else if (i % 5 == 0) {
- println("Ass")
- }
- else {
- println(i)
- }
- }
- }
- main(null)
Add Comment
Please, Sign In to add comment