Skip to content

Instantly share code, notes, and snippets.

@Tricky1975
Last active December 19, 2023 13:29
Show Gist options
  • Save Tricky1975/96fb71dc68247e23dcc40c03060a8c6b to your computer and use it in GitHub Desktop.
Save Tricky1975/96fb71dc68247e23dcc40c03060a8c6b to your computer and use it in GitHub Desktop.
#include <iostream>
#include <string>
#include <stdio.h>
using namespace std;
string a{""};
int main(){
for(int i=1;i<=9;++i){
a+=to_string(i);
auto l{stol(a)};
printf("%9s x 8 + %d = %d\n",a.c_str(),i,l*8+i);
}
return 0;
}
// Really, mathematics never ceases to amaze me.
@Tricky1975
Copy link
Author

Tricky1975 commented Dec 19, 2023

Output:

        1 x 8 + 1 = 9
       12 x 8 + 2 = 98
      123 x 8 + 3 = 987
     1234 x 8 + 4 = 9876
    12345 x 8 + 5 = 98765
   123456 x 8 + 6 = 987654
  1234567 x 8 + 7 = 9876543
 12345678 x 8 + 8 = 98765432
123456789 x 8 + 9 = 987654321

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment