summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--python/linear-log.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/python/linear-log.py b/python/linear-log.py
new file mode 100644
index 0000000..6863b2c
--- /dev/null
+++ b/python/linear-log.py
@@ -0,0 +1,11 @@
+import math
+
+def f(n):
+ x = n/1000.0
+ if x > 10:
+ x = 10 + math.log(x**3)
+ return min(100, max(1, int(x)))
+
+for i in [1,5,10,500,1000,5000,10000,50000,100000,500000,1000000,10000000]:
+ print("%d --- %d"%(i,f(i)))
+