Using "while loop" for factorial

I need to write a complete program using "While Loop" to calculate 1! to 12! using just "int" variables. Only from 1 to 12 and there are no other inputs..
This is my first time using While loop.
I have tried (factorial *= n)... I can't figure it out.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>
#include <iomanip>

int main()
{
    const int MIN = 1 ;
    const int MAX = 12 ;

    int n = MIN ;

    while( n <= MAX )
    {
        int factorial = 1 ;

        int i = 2 ;

        while( i <= n )
        {
            factorial *= i ;
            ++i ;
        }

        std::cout << std::setw(2) << n << "! == " << std::setw(9) << factorial << '\n' ;
        ++n ;
    }

}
Topic archived. No new replies allowed.