Joined
·
1,270 Posts
I don't even understand what you're trying to accomplish with that code but your for loop initialises the iterating variable i = 1 and then ends while i <= 1, therefore, only undergoing one iteration of the code in the loop. So, an output of "1 != 1" seems about right.
#include <iostream>
using namespace std;
int main(){
int num;
cin >> num;
unsigned long long int factorial = 1;
while(num > 1){
factorial *= num--;
}
cout << factorial;
return 0;
}