JSFiddle - React, Tailwind, and code Playground JavaScript for(n=prompt(a=0),j=1;j<=n;j*=2)for(i=j;i<=n;n<i+j&&a++,i+=2*j);alert(a)