fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. //=============================================
  5. long F(long n) {
  6. long F1 = 1;
  7.  
  8. if(n==1) { return 3; }
  9. else {
  10. for(long i = 1; i <= n; i++) {
  11. long C = 0;
  12. // Note: the belore For loop only has one line
  13. for(long j = 1; j <= n-1; j++) { C = C+1; }
  14. // At the end of this for loop, C will be = (n-1)
  15. F1 = F1 * C;
  16. }
  17. }
  18. return F1;
  19. }
  20. //=============================================
  21.  
  22. int main() {
  23.  
  24. for(long i = 1; i < 10; i++)
  25. printf("\nF(%ld) = %ld", i, F(i));
  26. return 0;
  27. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
F(1) = 3
F(2) = 1
F(3) = 8
F(4) = 81
F(5) = 1024
F(6) = 15625
F(7) = 279936
F(8) = 5764801
F(9) = 134217728