Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
12
Task/Tau-function/Haskell/tau-function.hs
Normal file
12
Task/Tau-function/Haskell/tau-function.hs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
tau :: Integral a => a -> a
|
||||
tau n | n <= 0 = error "Not a positive integer"
|
||||
tau n = go 0 (1, 1)
|
||||
where
|
||||
yo i = (i, i * i)
|
||||
go r (i, ii)
|
||||
| n < ii = r
|
||||
| n == ii = r + 1
|
||||
| 0 == mod n i = go (r + 2) (yo $ i + 1)
|
||||
| otherwise = go r (yo $ i + 1)
|
||||
|
||||
main = print $ map tau [1..100]
|
||||
Loading…
Add table
Add a link
Reference in a new issue