Thanks to @Raihan142857 for the idea. What number challenge are we on now? Anyway, the goal of this challenge is to codegolf a function that takes in a positive integer n, and determines what the sum of that number's digits are when it is converted to binary. Blocks are counted by removing any preliminary demonstration scripts, and then right-clicking the blocks area.
This contains a recursive function to calculate the popcount of an integer. This would be faster if we could use a return instruction and/or bitwise operators in Scratch. This would be a more optimized code (10 instructions, optimized for time): function popcount(n) { if(n) return 1+popcount(n&n-1); return 0; } or this one, optimized for space (5 instructions): function popcount(n) { return n&1+popcount(n>>1); } Obviously, on modern processors, there exists an intrinsic to calculate a popcount in just 1 instruction (but that would kinda be too easy).