about summary refs log tree commit diff
path: root/daily/286easy
diff options
context:
space:
mode:
Diffstat (limited to 'daily/286easy')
-rwxr-xr-xdaily/286easy/lairotcafbin0 -> 148836 bytes
-rw-r--r--daily/286easy/lairotcaf.inp6
-rw-r--r--daily/286easy/lairotcaf.obin0 -> 4976 bytes
-rw-r--r--daily/286easy/lairotcaf.out6
-rw-r--r--daily/286easy/lairotcaf.pas31
-rw-r--r--daily/286easy/problem.html25
-rw-r--r--daily/286easy/problem.md41
7 files changed, 109 insertions, 0 deletions
diff --git a/daily/286easy/lairotcaf b/daily/286easy/lairotcaf
new file mode 100755
index 0000000..68e22b8
--- /dev/null
+++ b/daily/286easy/lairotcaf
Binary files differdiff --git a/daily/286easy/lairotcaf.inp b/daily/286easy/lairotcaf.inp
new file mode 100644
index 0000000..ea4419c
--- /dev/null
+++ b/daily/286easy/lairotcaf.inp
@@ -0,0 +1,6 @@
+3628800
+479001600
+6
+18
+150
+120
diff --git a/daily/286easy/lairotcaf.o b/daily/286easy/lairotcaf.o
new file mode 100644
index 0000000..ebc1810
--- /dev/null
+++ b/daily/286easy/lairotcaf.o
Binary files differdiff --git a/daily/286easy/lairotcaf.out b/daily/286easy/lairotcaf.out
new file mode 100644
index 0000000..9916cd0
--- /dev/null
+++ b/daily/286easy/lairotcaf.out
@@ -0,0 +1,6 @@
+3628800 = 10!
+479001600 = 12!
+6 = 3!
+18 NONE
+150 NONE
+120 = 5!
diff --git a/daily/286easy/lairotcaf.pas b/daily/286easy/lairotcaf.pas
new file mode 100644
index 0000000..ef2c910
--- /dev/null
+++ b/daily/286easy/lairotcaf.pas
@@ -0,0 +1,31 @@
+var
+  fi, fo: text;
+  n, i: int64;
+
+begin
+  assign(fi, 'lairotcaf.inp');
+  assign(fo, 'lairotcaf.out');
+  reset(fi);
+  rewrite(fo);
+  repeat
+    readln(fi, n);
+    write(fo, n);
+    if n > 0 then
+      begin
+        i := 2;
+        while n mod i = 0 do
+          begin
+            n := n div i;
+            inc(i)
+          end;
+        if n = 1 then
+          begin
+            writeln(fo, ' = ', i - 1, '!');
+            continue
+          end
+      end;
+    writeln(fo, ' NONE')
+  until eof(fi);
+  close(fi);
+  close(fo)
+end.
diff --git a/daily/286easy/problem.html b/daily/286easy/problem.html
new file mode 100644
index 0000000..362cc50
--- /dev/null
+++ b/daily/286easy/problem.html
@@ -0,0 +1,25 @@
+<h1 id="description">Description</h1>
+<p>Nearly everyone is familiar with the factorial operator in math. 5! yields 120 because factorial means &quot;multiply successive terms where each are one less than the previous&quot;:</p>
+<pre><code>5! -&gt; 5 * 4 * 3 * 2 * 1 -&gt; 120</code></pre>
+<p>Simple enough.</p>
+<p>Now let's reverse it. Could you write a function that tells us that &quot;120&quot; is &quot;5!&quot;?</p>
+<p>Hint: The strategy is pretty straightforward, just divide the term by successively larger terms until you get to &quot;1&quot; as the resultant:</p>
+<pre><code>120 -&gt; 120/2 -&gt; 60/3 -&gt; 20/4 -&gt; 5/5 -&gt; 1 =&gt; 5!</code></pre>
+<h1 id="sample-input">Sample Input</h1>
+<p>You'll be given a single integer, one per line. Examples:</p>
+<pre><code>120
+150</code></pre>
+<h1 id="sample-output">Sample Output</h1>
+<p>Your program should report what each number is as a factorial, or &quot;NONE&quot; if it's not legitimately a factorial. Examples:</p>
+<pre><code>120 = 5!
+150   NONE</code></pre>
+<h1 id="challenge-input">Challenge Input</h1>
+<pre><code>3628800
+479001600
+6
+18</code></pre>
+<h1 id="challenge-output">Challenge Output</h1>
+<pre><code>3628800 = 10!
+479001600 = 12!
+6 = 3!
+18  NONE</code></pre>
diff --git a/daily/286easy/problem.md b/daily/286easy/problem.md
new file mode 100644
index 0000000..8715cbe
--- /dev/null
+++ b/daily/286easy/problem.md
@@ -0,0 +1,41 @@
+# Description
+
+Nearly everyone is familiar with the factorial operator in math. 5! yields 120 because factorial means "multiply successive terms where each are one less than the previous":
+
+    5! -> 5 * 4 * 3 * 2 * 1 -> 120
+
+Simple enough. 
+
+Now let's reverse it. Could you write a function that tells us that "120" is "5!"? 
+
+Hint: The strategy is pretty straightforward, just divide the term by successively larger terms until you get to "1" as the resultant:
+
+    120 -> 120/2 -> 60/3 -> 20/4 -> 5/5 -> 1 => 5!
+
+# Sample Input
+
+You'll be given a single integer, one per line. Examples:
+
+    120
+    150
+
+# Sample Output
+
+Your program should report what each number is as a factorial, or "NONE" if it's not legitimately a factorial. Examples:
+
+    120 = 5!
+    150   NONE
+
+# Challenge Input
+
+    3628800
+    479001600
+    6
+    18
+
+# Challenge Output
+
+    3628800 = 10!
+    479001600 = 12!
+    6 = 3!
+    18  NONE