function* factorial(n) {
  
  n = parseInt(n)
  
  if (isNaN(n)) {
    yield new Error('n is not a number')
    return
  }

  if (n < 0) {
    yield new Error('n is negative')
    return
  }

  if (n === 0) {
    n = 1
  }

  let x = 1
  let m = 0

  while(m < n) {
    x = x * ++m
    yield x
  }
}
/**
 * When iterated returns arrays of factorials of integers from 1 to n
 * @param number n - value to stop at
 */
When iterated returns arrays of factorials of integers from 1 to n
@param number n - value to stop at
When iterated returns arrays of factorials of integers from 1 to n @param number n - value to stop at
function* factorial(n) {
  n = parseInt(n)
  if (isNaN(n)) {
    yield new Error('n is not a number')
    return
  }
  if (n < 0) {
    yield new Error('n is negative')
    return
  }
  if (n === 0) {
    n = 1
  }
  let x = 1
  let m = 0
  while(m < n) {
    x = x * ++m
    yield x
  }
}
function * factorial ( n ) { n = parseInt ( n ) if ( isNaN ( n ) ) { yield new Error ( 'n is not a number' ) return } if ( n < 0 ) { yield new Error ( 'n is negative' ) return } if ( n === 0 ) { n = 1 } let x = 1 let m = 0 while ( m < n ) { x = x * ++ m yield x } }
When iterated returns arrays of factorials of integers from 1 to n
 @param number n - value to stop at
When iterated returns arrays of factorials of integers from 1 to n @param number n - value to stop at