$prime(N[,N])[.prev|next] $prime(5) => $true $prime(4) => $false $prime(4).next => 5 $prime(4).prev => 3 $prime(6,1) => 5 OR 7 $prime(6,2) => 5,7 $prime(6,2).next => 7,11 $prime(6,2).prev => 5,3 [b]Prime numbers[/b] As in the style of most of my challenges this is split up into sections which contain tasks of varying difficulty. you may only enter ONE section [b]Beginners[/b] [b]Syntax:[/b] $prime(N) [b]Rules:[/b] - You may assume that $1 will always be an integer greater than 1, and that input will always be valid - if N is a prime number you should return $true - if N is not a prime number you should return either $false or $null [b]Examples:[/b] $prime(5) => $true $prime(9) => $false OR $null [b]Intermediate:[/b] [b]Syntax:[/b] $prime(N)[.prev|.next] [b]Rules:[/b] - You may assume that $1 will always be a valid input, however if $2 exists you should return $false (or $null) - if $1 is a prime number you should return $true - even if a property is specified - if $1 is not a prime number and no property is specified (or if the property is not prev or next) you should return $false - if $1 is not a prime number and the property is prev or next you should return the previous, or the next prime number respectively [b]Examples:[/b] $prime(5) => $true $prime(5).next => $true $prime(4) => $false $prime(4).next => 5 $prime(4).prev => 3 $prime(-4) => $false $prime(4,5) => $false (OR $null) [b]Advanced:[/b] [b]Syntax:[/b] $prime(N[,N])[.prev|.next] [b]Rules:[/b] - if $1 is a prime number you should return $true - even if a property is specified - if $1 is not a prime number and no property is specified (or if the property is not prev or next) you should return $false - if $1 is not a prime number and the property is prev or next you should return the previous, or the next prime number respectively - if $2 is given and the property is either prev or next you should return the previous or next N prime numbers respectively - if $2 is given but no valid property (ie prev or next) is specified you should return the closet N integers sorted by how far they are from $1 - When returning multiple numbers, they should be comma delimited - you may assume that both $1 and $2 will be valid - however if $2 exists you should return $false (or $null) [b]Examples:[/b] [i] ALl examples from the intermediate section apply here as well - apart from the final one, which is redefined here[/i] $prime(5,2) => $true $prime(8,2) => 7,5 OR 7,11 $prime(8,3) => 7,5,11 $prime(8,4).next => 11,13,17,19 $prime(8,4).prev => 7,5,3,-1 $prime(-5) => $true $prime(4,5) => -1,3,5,7 OR -1,5,3,7