Hacker News new | past | comments | ask | show | jobs | submit login

This problem is like Project Euler #1. You don't strictly need to divide. I prefer to skip along the array and put in the new values.

  n,f,b= 100,3,5
  a = [str(i) for i in range(1,n+1)]
  for i in range(n/f):
      a[(i+1)*(f)-1] = 'Fizz'
  for i in range(n/b):
      a[(i+1)*(b)-1] = 'Buzz'
  for i in range(n/(f*b)):
      a[(i+1)*(f*b)-1] = 'FizzBuzz'



Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: