Skip to main content
edited body
Source Link
VolAnd
  • 296
  • 3
  • 8

C++, 54 51 bytes

[](int N,int P){int F;for(F=N;P;F-=++N,P--);return F;}

 [](int N,int P){int F=N;while(P--)F-=++N;return F;} 

[](int N,int P){int F;for(F=N;P;F-=++N,P--);return F;}

Test:

#include <iostream> int main(void) { int N, P; std::cin >> N >> P; auto f = [](int N,int P){int F=N;while(P--)F-=++N;return F;}; std::cout << f(N,P) << std::endl; return 0; } 

C++, 54 51 bytes

[](int N,int P){int F;for(F=N;P;F-=++N,P--);return F;}

 [](int N,int P){int F=N;while(P--)F-=++N;return F;} 

Test:

#include <iostream> int main(void) { int N, P; std::cin >> N >> P; auto f = [](int N,int P){int F=N;while(P--)F-=++N;return F;}; std::cout << f(N,P) << std::endl; return 0; } 

C++, 54 51 bytes

 [](int N,int P){int F=N;while(P--)F-=++N;return F;} 

[](int N,int P){int F;for(F=N;P;F-=++N,P--);return F;}

Test:

#include <iostream> int main(void) { int N, P; std::cin >> N >> P; auto f = [](int N,int P){int F=N;while(P--)F-=++N;return F;}; std::cout << f(N,P) << std::endl; return 0; } 
added 71 characters in body
Source Link
VolAnd
  • 296
  • 3
  • 8

C++, 5454 51 bytes

[](int N,int P){int F;for(F=N;P;F-=++N,P--);return F;}

 [](int N,int P){int F;forF=N;while(F=N;P;F-=++N,P--);returnF-=++N;return F;} 

Test:

#include <iostream> int main(void) { int N, P; std::cin >> N >> P; auto f = [](int N,int P){int F;forF=N;while(F=N;P;F-=++N,P--);returnF-=++N;return F;}; std::cout << f(N,P) << std::endl; return 0; } 

C++, 54 bytes

[](int N,int P){int F;for(F=N;P;F-=++N,P--);return F;} 

Test:

#include <iostream> int main(void) { int N, P; std::cin >> N >> P; auto f = [](int N,int P){int F;for(F=N;P;F-=++N,P--);return F;}; std::cout << f(N,P) << std::endl; return 0; } 

C++, 54 51 bytes

[](int N,int P){int F;for(F=N;P;F-=++N,P--);return F;}

 [](int N,int P){int F=N;while(P--)F-=++N;return F;} 

Test:

#include <iostream> int main(void) { int N, P; std::cin >> N >> P; auto f = [](int N,int P){int F=N;while(P--)F-=++N;return F;}; std::cout << f(N,P) << std::endl; return 0; } 
added 392 characters in body
Source Link
VolAnd
  • 296
  • 3
  • 8

C/C++, 2254 bytes

for[](int N,int P){int F;for(F=N;P;F-=++N,P--);;return F;} 

Test:

#include <iostream> int main(void) { int N, P; std::cin >> N >> P; auto f = [](int N,int P){int F;for(F=N;P;F-=++N,P--);return F;}; std::cout << f(N,P) << std::endl; return 0; } 

C/C++, 22 bytes

for(F=N;P;F-=++N,P--); 

C++, 54 bytes

[](int N,int P){int F;for(F=N;P;F-=++N,P--);return F;} 

Test:

#include <iostream> int main(void) { int N, P; std::cin >> N >> P; auto f = [](int N,int P){int F;for(F=N;P;F-=++N,P--);return F;}; std::cout << f(N,P) << std::endl; return 0; } 
Source Link
VolAnd
  • 296
  • 3
  • 8
Loading