#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin >> n >> m; int sock = n; int count = 0; while (sock > 0) { count+=1; if (sock % m == 0) { sock++; } sock--; } cout << count << endl; return 0; }
if (sock % m == 0) { sock++; } sock--; // If you add 1 to sock and then subtract 1 it will go on for ever
sock
m
cout
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)