summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorSanto Cariotti <sancn@live.com>2017-05-15 18:04:14 +0200
committerSanto Cariotti <sancn@live.com>2017-05-15 18:04:14 +0200
commitb8e30c8bb04c11ccaa31b6e89a452ee66d372b0b (patch)
tree4261f0f75ac9e8f8d9e9b01c4c6353912d9c6b5d /cpp
parent46d6c42c81be3c2b78254e009945578e10fab611 (diff)
fixed spaces
Diffstat (limited to 'cpp')
-rw-r--r--cpp/somme.cpp12
1 files changed, 2 insertions, 10 deletions
diff --git a/cpp/somme.cpp b/cpp/somme.cpp
index e42ad64..df8f8ee 100644
--- a/cpp/somme.cpp
+++ b/cpp/somme.cpp
@@ -6,22 +6,16 @@ output: 1
#include <iostream>
#include <fstream>
-bool pari(int n)
-{
- return ((n % 2) == 0) ? true : false;
-}
+bool pari(int n) { return ((n % 2) == 0) ? true : false; }
int sequenza(int n, bool pollatz, int tCollatz = -1)
{
- int m;
+ int m, tot = 1;
if(pollatz)
m = 5;
else
m = 3;
-
- int tot = 1;
-
while(n != 1) {
if(pari(n))
@@ -29,12 +23,10 @@ int sequenza(int n, bool pollatz, int tCollatz = -1)
else
n = n*m+1;
-
tot++;
if(tCollatz != -1 && tot > tCollatz)
break;
-
}
return tot;