#include <iostream>
template < int N>
constexpr int factorial( ) {
return N* factorial< N- 1 > ( ) ;
}
template <>
constexpr int factorial< 0 > ( ) {
return 1 ;
}
template <>
constexpr int factorial< 1 > ( ) {
return 1 ;
}
struct factorials{
constexpr static int tab[ 9 ] { factorial< 1 > ( ) , factorial< 2 > ( ) , factorial< 3 > ( ) , factorial< 4 > ( ) , factorial< 5 > ( ) , factorial< 6 > ( ) , factorial< 7 > ( ) , factorial< 8 > ( ) , factorial< 9 > ( ) } ;
} ;
int main( ) {
for ( int i= 0 ; i< 9 ; i++ ) {
std:: cout << factorials:: tab [ i] << std:: endl ;
}
return 0 ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgoKdGVtcGxhdGU8aW50IE4+CmNvbnN0ZXhwciBpbnQgZmFjdG9yaWFsKCl7CglyZXR1cm4gTipmYWN0b3JpYWw8Ti0xPigpOwp9CnRlbXBsYXRlPD4KY29uc3RleHByIGludCBmYWN0b3JpYWw8MD4oKXsKCXJldHVybiAxOwp9CnRlbXBsYXRlPD4KY29uc3RleHByIGludCBmYWN0b3JpYWw8MT4oKXsKCXJldHVybiAxOwp9CnN0cnVjdCBmYWN0b3JpYWxzewoJY29uc3RleHByIHN0YXRpYyBpbnQgdGFiWzlde2ZhY3RvcmlhbDwxPigpLCBmYWN0b3JpYWw8Mj4oKSwgZmFjdG9yaWFsPDM+KCksIGZhY3RvcmlhbDw0PigpLCBmYWN0b3JpYWw8NT4oKSwgZmFjdG9yaWFsPDY+KCksIGZhY3RvcmlhbDw3PigpLCBmYWN0b3JpYWw8OD4oKSwgZmFjdG9yaWFsPDk+KCl9Owp9OwoKaW50IG1haW4oKSB7Cglmb3IoaW50IGk9MDsgaTw5OyBpKyspewoJCXN0ZDo6Y291dCA8PCBmYWN0b3JpYWxzOjp0YWJbaV0gPDwgc3RkOjplbmRsOwoJfQoJcmV0dXJuIDA7Cn0=