[ create a new paste ] login | about

Link: http://codepad.org/xwuljADK    [ raw code | output | fork ]

mohit_at_codepad - C, pasted on Jun 11:
// find fraction that support fallacy proof (howlers)
#include <stdio.h>
//#define const

void printFallacyDecends(int n, int d) {
  const int ns[] = {n/10, n%10};
  const int ds[] = {d/10, d%10};
  if( (ns[1] == ds[0])
       && (ns[0] * d == n * ds[1]) ) {
    printf("%d/%d = %d/%d\n", n, d, ns[0], ds[1]);
  }
  if( (ns[0] == ds[1])
       && (ns[1] * d == n * ds[0]) ) {
    printf("%d/%d = %d/%d\n", n, d, ns[1], ds[0]);
  }
}

int main() {
  int i = 0, j = 0;
  for(i = 11; i < 100-1; ++i)
  for(j = i+1; j < 100; ++j) printFallacyDecends(i, j);
  return 0;
}


Output:
1
2
3
4
16/64 = 1/4
19/95 = 1/5
26/65 = 2/5
49/98 = 4/8


Create a new paste based on this one


Comments: