DEV Community

Discussion on: A pure functional Primality Test in Scala

Collapse
 
rleibman profile image
Roberto Leibman

I think a better practice would be to have an inner function (traditionally called loop), that way your caller doesn't need to know the dirty details of you using recursion. Also.... you probably want to add @tailrec, to make sure your function can be optimized by the compiler.

Collapse
 
rleibman profile image
Roberto Leibman

Plus an implicit int is a really bad idea!

Collapse
 
guildenstern70 profile image
Alessio Saltarin

I am not sure the function is tail recursive...