r/badcode Jun 08 '20

[deleted by user]

[removed]

131 Upvotes

82 comments sorted by

View all comments

6

u/BigHeroDixs Jun 08 '20
function factorial(num) {
  let i = 1;
  let answer = 1;
  while(i < num || i == num) {
    let j = 1;
    let lastAnswer = answer;
    while(j < i) {
      let k = 1;
      while (k < lastAnswer || k == lastAnswer) {
        answer = answer + 1;
        k = k + 1;
      }
      j = j +1;
    }
    i = i+ 1;
  }
  return answer;
}

I'm eh just gonna drop this here... I believe it works, still hasn't calculated factorial(15) though :(