#!/usr/bin/env perl use strict; use warnings; my $n = <>; chomp $n; my %h; $h{1} = 1; for (my $i = 2; $i < 50; $i++) { $h{$i} = ($h{$i - 1} * $i) % 1000000000000; } if ($n >= 50) { print "000000000000\n"; } else { printf("%d\n", $h{$n}); }