summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSanto Cariotti <sancn@live.com>2017-05-16 16:47:24 +0200
committerSanto Cariotti <sancn@live.com>2017-05-16 16:47:24 +0200
commita945361789d3bf06475950803a64fb31180ce379 (patch)
tree9d0559877131b39788b8b1bfc3a160d63ec4882e
parentf1d043e2bed937f1e067df1834030227e83f5430 (diff)
use lambda function for pari
-rw-r--r--cpp/somme.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/cpp/somme.cpp b/cpp/somme.cpp
index df8f8ee..c112e8f 100644
--- a/cpp/somme.cpp
+++ b/cpp/somme.cpp
@@ -6,8 +6,6 @@ output: 1
#include <iostream>
#include <fstream>
-bool pari(int n) { return ((n % 2) == 0) ? true : false; }
-
int sequenza(int n, bool pollatz, int tCollatz = -1)
{
int m, tot = 1;
@@ -16,6 +14,11 @@ int sequenza(int n, bool pollatz, int tCollatz = -1)
m = 5;
else
m = 3;
+
+ auto pari = [] (int n) {
+ return ((n % 2) == 0) ? true : false;
+ };
+
while(n != 1) {
if(pari(n))