Data update
This commit is contained in:
parent
9817d9b99b
commit
07c7092a52
140 changed files with 2712 additions and 241 deletions
12
Task/Tau-function/Haskell/tau-function-1.hs
Normal file
12
Task/Tau-function/Haskell/tau-function-1.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