[ create a new paste ] login | about

Link: http://codepad.org/tLsNJ6Nc    [ raw code | output | fork | 1 comment ]

mohit_at_codepad - C, pasted on Jun 11:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// find fraction that support fallacy proof (howlers)
#include <stdio.h>
//#define const

void printFallacyDecends(int n, int d) {
  int i = 0;
  for(i = 1; i < 10; ++i) {
    const int nn = n * 10 + i;
    const int dd = i * 10 + d;
    if(dd * n == d * nn) printf("%d/%d = %d/%d\n", nn, dd, n, d);
  }
}

int main() {
  int i = 0, j = 0;
  for(i = 1; i < 10-1; ++i)
  for(j = i+1; j < 10; ++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:
posted by mohit_at_codepad on Jun 11
In another variation you can verify __gcd(n, d) is 1. This will remove 49/98 = 4/8.
reply