From 9921a63959959966cdcb05e7e99873e092feea63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?I=C5=9F=C4=B1nsu=20Ar=C4=B1c=C4=B1?= Date: Sat, 29 Jan 2022 23:43:49 +0300 Subject: [PATCH] 1688 --- E_1688_CountofMatchesinTournament.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 E_1688_CountofMatchesinTournament.java diff --git a/E_1688_CountofMatchesinTournament.java b/E_1688_CountofMatchesinTournament.java new file mode 100644 index 0000000..dcbcdaf --- /dev/null +++ b/E_1688_CountofMatchesinTournament.java @@ -0,0 +1,17 @@ +public class Solution { + public int numberOfMatches(int n) { + int matches = 0; + while(n!=1) { + if (n % 2 == 0) { //çiftse + n = n / 2; + matches += n; + + } else { //tekse + n = ((n - 1) / 2); + matches += n; + n = n + 1; + } + } + return matches; + } +} \ No newline at end of file