Skip to content

Instantly share code, notes, and snippets.

@WillNess
Created July 30, 2013 13:56
Show Gist options
  • Select an option

  • Save WillNess/6113118 to your computer and use it in GitHub Desktop.

Select an option

Save WillNess/6113118 to your computer and use it in GitHub Desktop.
divisors one-liner
divs n = concat $ unfoldr (\(n,i)->case n of 1->Nothing;
_->if i*i>n then Just([n], (1,i)) else case rem n i of {0->Just([i], (div n i,i)
); _->Just([], (n,i+1))}) (n,2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment