fork download
  1. #include <iostream>
  2.  
  3. template < typename Int >
  4. Int silnia( Int input )
  5. {
  6. Int ret = 1;
  7. for ( Int it = 2; it <= input; ++it )
  8. ret *= it;
  9. return ret;
  10. }
  11.  
  12. int main( )
  13. {
  14. std::cout << "int: " << std::endl;
  15. for ( int it = 1; it < 30; ++it )
  16. std::cout << it << ": " << silnia(it) << std::endl;
  17.  
  18. std::cout << "unsigned: " << std::endl;
  19. for ( int it = 1; it < 30; ++it )
  20. std::cout << it << ": " << silnia<unsigned>(it) << std::endl;
  21.  
  22. std::cout << "long long: " << std::endl;
  23. for ( int it = 1; it < 30; ++it )
  24. std::cout << it << ": " << silnia<long long>(it) << std::endl;
  25.  
  26. std::cout << " unsigned long long: " << std::endl;
  27. for ( int it = 1; it < 30; ++it )
  28. std::cout << it << ": " << silnia<unsigned long long>(it) << std::endl;
  29.  
  30. return 0;
  31. }
Success #stdin #stdout 0s 3344KB
stdin
Standard input is empty
stdout
int: 
1: 1
2: 2
3: 6
4: 24
5: 120
6: 720
7: 5040
8: 40320
9: 362880
10: 3628800
11: 39916800
12: 479001600
13: 1932053504
14: 1278945280
15: 2004310016
16: 2004189184
17: -288522240
18: -898433024
19: 109641728
20: -2102132736
21: -1195114496
22: -522715136
23: 862453760
24: -775946240
25: 2076180480
26: -1853882368
27: 1484783616
28: -1375731712
29: -1241513984
unsigned: 
1: 1
2: 2
3: 6
4: 24
5: 120
6: 720
7: 5040
8: 40320
9: 362880
10: 3628800
11: 39916800
12: 479001600
13: 1932053504
14: 1278945280
15: 2004310016
16: 2004189184
17: 4006445056
18: 3396534272
19: 109641728
20: 2192834560
21: 3099852800
22: 3772252160
23: 862453760
24: 3519021056
25: 2076180480
26: 2441084928
27: 1484783616
28: 2919235584
29: 3053453312
long long: 
1: 1
2: 2
3: 6
4: 24
5: 120
6: 720
7: 5040
8: 40320
9: 362880
10: 3628800
11: 39916800
12: 479001600
13: 6227020800
14: 87178291200
15: 1307674368000
16: 20922789888000
17: 355687428096000
18: 6402373705728000
19: 121645100408832000
20: 2432902008176640000
21: -4249290049419214848
22: -1250660718674968576
23: 8128291617894825984
24: -7835185981329244160
25: 7034535277573963776
26: -1569523520172457984
27: -5483646897237262336
28: -5968160532966932480
29: -7055958792655077376
 unsigned long long: 
1: 1
2: 2
3: 6
4: 24
5: 120
6: 720
7: 5040
8: 40320
9: 362880
10: 3628800
11: 39916800
12: 479001600
13: 6227020800
14: 87178291200
15: 1307674368000
16: 20922789888000
17: 355687428096000
18: 6402373705728000
19: 121645100408832000
20: 2432902008176640000
21: 14197454024290336768
22: 17196083355034583040
23: 8128291617894825984
24: 10611558092380307456
25: 7034535277573963776
26: 16877220553537093632
27: 12963097176472289280
28: 12478583540742619136
29: 11390785281054474240