Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 134 characters in body
Source Link
Emigna
  • 53.2k
  • 5
  • 44
  • 164

05AB1E, 34 bytes

Uses Jonathan's mathematical insight that ceil(n/3+3) = floor((n+8)//3)+1

ŽJćG8+‚2L>÷>Ns×ばつJNIв‚õKн,

Try it online!

Explanation

ŽJćG # for N in [1 ...5001)
 8+‚2L>÷> # push [input//2+1, (input+8)//3+1]
 NsÖ # check each if N is divisible by it
 ...TMÁzz # push "fizz"
 'ÒÖ # push "buzz"
 ‚ # pair
 ×ばつ # repeat a number of times corresponding to the result of the 
 # divisibility test
 J # join to string
 NIв‚ # pair with N converted to base <input>
 õK # remove empty string
 н, # print head of the remaining list

05AB1E, 34 bytes

ŽJćG8+‚2L>÷>Ns×ばつJNIв‚õKн,

Try it online!

Explanation

ŽJćG # for N in [1 ...5001)
 8+‚2L>÷> # push [input//2+1, (input+8)//3+1]
 NsÖ # check each if N is divisible by it
 ...TMÁzz # push "fizz"
 'ÒÖ # push "buzz"
 ‚ # pair
 ×ばつ # repeat a number of times corresponding to the result of the 
 # divisibility test
 J # join to string
 NIв‚ # pair with N converted to base <input>
 õK # remove empty string
 н, # print head of the remaining list

05AB1E, 34 bytes

Uses Jonathan's mathematical insight that ceil(n/3+3) = floor((n+8)//3)+1

ŽJćG8+‚2L>÷>Ns×ばつJNIв‚õKн,

Try it online!

Explanation

ŽJćG # for N in [1 ...5001)
 8+‚2L>÷> # push [input//2+1, (input+8)//3+1]
 NsÖ # check each if N is divisible by it
 ...TMÁzz # push "fizz"
 'ÒÖ # push "buzz"
 ‚ # pair
 ×ばつ # repeat a number of times corresponding to the result of the 
 # divisibility test
 J # join to string
 NIв‚ # pair with N converted to base <input>
 õK # remove empty string
 н, # print head of the remaining list
Source Link
Emigna
  • 53.2k
  • 5
  • 44
  • 164

05AB1E, 34 bytes

ŽJćG8+‚2L>÷>Ns×ばつJNIв‚õKн,

Try it online!

Explanation

ŽJćG # for N in [1 ...5001)
 8+‚2L>÷> # push [input//2+1, (input+8)//3+1]
 NsÖ # check each if N is divisible by it
 ...TMÁzz # push "fizz"
 'ÒÖ # push "buzz"
 ‚ # pair
 ×ばつ # repeat a number of times corresponding to the result of the 
 # divisibility test
 J # join to string
 NIв‚ # pair with N converted to base <input>
 õK # remove empty string
 н, # print head of the remaining list

AltStyle によって変換されたページ (->オリジナル) /