Skip to main content
added 87 characters in body
Source Link
Mr. Xcoder
  • 42.9k
  • 9
  • 87
  • 221

Swift 4, 6258 bytes

let n=Int(readLine()!)!;print(1<n&&(21..<n).filter{n%$0<1}==[]==[1]) 

Try it online!Try it online!

Saved a few bytes thanks to Dennis.

Swift 4, 62 bytes

let n=Int(readLine()!)!;print(1<n&&(2..<n).filter{n%$0<1}==[]) 

Try it online!

Swift 4, 58 bytes

let n=Int(readLine()!)!;print((1..<n).filter{n%$0<1}==[1]) 

Try it online!

Saved a few bytes thanks to Dennis.

deleted 329 characters in body
Source Link
Mr. Xcoder
  • 42.9k
  • 9
  • 87
  • 221

#Swift 4, 62 bytes

Swift 4, 62 bytes

varlet n=Int(readLine()!)!;print(1<n&&(2..<n).filter{n%$0<1}==[]) 

Try it here! (now this service has been deprecated; the code is slightly modified in order to work there too, temporarily at least)

Note that this can only be ran from the command line, due to readLine(), the only way of taking input in Swift without a function.Try it online!

#Swift 4, 62 bytes

var n=Int(readLine()!)!;print(1<n&&(2..<n).filter{n%$0<1}==[]) 

Try it here! (now this service has been deprecated; the code is slightly modified in order to work there too, temporarily at least)

Note that this can only be ran from the command line, due to readLine(), the only way of taking input in Swift without a function.

Swift 4, 62 bytes

let n=Int(readLine()!)!;print(1<n&&(2..<n).filter{n%$0<1}==[]) 

Try it online!

added 4 characters in body
Source Link
Mr. Xcoder
  • 42.9k
  • 9
  • 87
  • 221

#Swift 4, 5862 bytes

var n=Int(readLine()!)!;print(1<n&&(2..<n).filter{n%$0<1}==[]) 

Try it here! (now this service has been deprecated; the code is slightly modified in order to work there too, temporarily at least)

Note that this can only be ran from the command line, due to readLine(), the only way of taking input in Swift without a function.

#Swift 4, 58 bytes

n=Int(readLine()!)!;print(1<n&&(2..<n).filter{n%$0<1}==[]) 

Try it here! (now this service has been deprecated; the code is slightly modified in order to work there too, temporarily at least)

Note that this can only be ran from the command line, due to readLine(), the only way of taking input in Swift without a function.

#Swift 4, 62 bytes

var n=Int(readLine()!)!;print(1<n&&(2..<n).filter{n%$0<1}==[]) 

Try it here! (now this service has been deprecated; the code is slightly modified in order to work there too, temporarily at least)

Note that this can only be ran from the command line, due to readLine(), the only way of taking input in Swift without a function.

added 140 characters in body
Source Link
Mr. Xcoder
  • 42.9k
  • 9
  • 87
  • 221
Loading
Source Link
Mr. Xcoder
  • 42.9k
  • 9
  • 87
  • 221
Loading