From 18022d73c1c3f86651e55b4ecf22d6f357c53d75 Mon Sep 17 00:00:00 2001
From: Santo Cariotti <sancn@live.com>
Date: Tue, 16 May 2017 17:19:31 +0200
Subject: modified somme.cpp and added somme.py

---
 cpp/somme.cpp | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

(limited to 'cpp')

diff --git a/cpp/somme.cpp b/cpp/somme.cpp
index c112e8f..240af3f 100644
--- a/cpp/somme.cpp
+++ b/cpp/somme.cpp
@@ -8,12 +8,7 @@ output: 1
 
 int sequenza(int n, bool pollatz, int tCollatz = -1)
 {
-	int m, tot = 1;
-	
-	if(pollatz)
-		m = 5;
-	else
-		m = 3;
+	int m = ((pollatz) ? 5 : 3), tot = 1;
 	
 	auto pari = [] (int n) {
 		return ((n % 2) == 0) ? true : false;
@@ -21,10 +16,7 @@ int sequenza(int n, bool pollatz, int tCollatz = -1)
 		
 
 	while(n != 1) {		
-		if(pari(n))
-			n /= 2;
-		else
-			n = n*m+1;
+		n = (pari(n)) ? n/2 : n*m+1;
 		
 		tot++;
 		
-- 
cgit v1.2.3-18-g5258