Haskell, (削除) 77 (削除ここまで) 76 bytes
import System.Random
f x=randomRIO(1,x)>>=(x!)
x!y|y<x=pure y|0<1=(y+)<$>f x
Thanks to killmous for one byte.
If <|> were in the prelude, we could do better with MonadComprehensions:
Haskell , non-competing, 66 bytes
import System.Random
f x=do y<-randomRIO(1,x);[y|y<x]<|>(y+)<$>f x
Haskell, (削除) 77 (削除ここまで) 76 bytes
import System.Random
f x=randomRIO(1,x)>>=(x!)
x!y|y<x=pure y|0<1=(y+)<$>f x
Thanks to killmous for one byte.
Haskell, (削除) 77 (削除ここまで) 76 bytes
import System.Random
f x=randomRIO(1,x)>>=(x!)
x!y|y<x=pure y|0<1=(y+)<$>f x
Thanks to killmous for one byte.
If <|> were in the prelude, we could do better with MonadComprehensions:
Haskell , non-competing, 66 bytes
import System.Random
f x=do y<-randomRIO(1,x);[y|y<x]<|>(y+)<$>f x
Haskell, 77(削除) 77 (削除ここまで) 76 bytes
import System.Random
f x=randomRIO(1,x)>>=g >>=(x!)
g x!y|y<x=pure y|0<1=(y+)<$>f x
Thanks to killmous for one byte.