From a945361789d3bf06475950803a64fb31180ce379 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Tue, 16 May 2017 16:47:24 +0200 Subject: use lambda function for pari --- cpp/somme.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'cpp') 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 #include -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)) -- cgit v1.2.3-18-g5258