Timeline for Not so triangular numbers
Current License: CC BY-SA 4.0
10 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 3, 2020 at 12:03 | history | edited | nthnchu | CC BY-SA 4.0 |
Remove unnecessary `(` and `)`, and change `Math.sqrt(`...`)` to ...`**.5`
|
Nov 3, 2020 at 2:46 | comment | added | Samathingamajig |
^ a=>(x=0,Array((a*a+a)/2).fill().map((a,b)=>x+=Math.ceil(c=(b+1)**.5)-c<.5),x)
|
|
Nov 3, 2020 at 0:26 | comment | added | Samathingamajig |
Down to 77 by removing unnecessary ( and ) , and changing how sqrt is done... Try it online!
|
|
Nov 3, 2020 at 0:10 | comment | added | Samathingamajig |
You can remove 2 bytes ( and ) with a=>(x=0,Array((a*a+a)/2).fill().map((a,b)=>x+=Math.ceil(c=Math.sqrt(b+1))-c<.5),x) TIO
|
|
Nov 2, 2020 at 23:48 | history | edited | nthnchu | CC BY-SA 4.0 |
Move `c=Math.sqrt(b+1)` inside `Math.ceil(c)` and omit the `f=`; Change ...`c<0.5` to ...`c<.5`
|
Nov 2, 2020 at 23:43 | comment | added | xnor |
I realized the 0.5 I wrote can be .5 .
|
|
Nov 2, 2020 at 23:42 | comment | added | user |
You can put c=... directly inside Math.ceil(c=Math...) and omit the f= (I think)
|
|
Nov 2, 2020 at 23:37 | history | edited | nthnchu | CC BY-SA 4.0 |
Change `a**2` to `a*a` and simplify `1-Math.ceil(c)+Math.round(c)` to `Math.ceil(c)-c<0.5`
|
Nov 2, 2020 at 23:28 | comment | added | xnor |
You can simplify to x+=Math.ceil(c)-c<0.5 , based on the simplified formula in my Python answer. It also looks like a**2 can be a*a .
|
|
Nov 2, 2020 at 23:26 | history | answered | nthnchu | CC BY-SA 4.0 |