Skip to content

Instantly share code, notes, and snippets.

@cordx56
Created November 14, 2016 12:06
Show Gist options
  • Save cordx56/c169b08fbf77cacfeedaf40c502bbe9b to your computer and use it in GitHub Desktop.
Save cordx56/c169b08fbf77cacfeedaf40c502bbe9b to your computer and use it in GitHub Desktop.
It outputs '56' to your console. That's all.
#include <iostream>
int math_fact(int n) {
int r = 1;
for (; n > 0; n--) {
r *= n;
}
return r;
}
int main() {
// 8!/(8-2)! == _8 P _2
int res = math_fact(8) / math_fact(8 - 2);
std::cout << res;
return 0;
}
<?php
function math_fact($n) {
$r = 1;
for (; $n > 0; $n--) {
$r *= $n;
}
return $r;
}
// 8!/(8-2)! == _8 P _2
$res = math_fact(8) / math_fact(8 - 2);
print $res;
?>
import math
# 8!/(8-2)! == _8 P _2
res = math.factorial(8) // math.factorial(8 - 2)
print(res)
public class Print56 {
public static void main(String args[]) {
// 8!/(8-2)! == _8 P _2
int res = math_fact(8) / math_fact(8 - 2);
System.out.print(res);
}
static int math_fact(int n) {
int r = 1;
for (; n > 0; n--) {
r *= n;
}
return r;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment