Determine the total number of quadruplets (p, q, r, s) of positive integers with p < q < r < s < 100, such that: p+s = q+r and, q*r - p*s = 94.
using the following Qbasic code
„ CLS 0
„ OPEN ".\output.txt" FOR OUTPUT AS #1
„ cnt = 0
„ FOR p = 1 TO 96
„ FOR q = p + 1 TO 97
„ FOR r = q + 1 TO 98
„ FOR s = r + 1 TO 99
„ IF p + s = q + r AND q * r - p * s = 94 THEN
„ cnt = cnt + 1
„ PRINT #1, cnt, p; q; r; s
„ END IF
„ NEXT s
„ NEXT r
„ NEXT q
„ NEXT p
„ CLOSE #1
I found the following 54 solutions
1 1 2 95 96
2 1 3 48 50
3 2 3 96 97
4 2 4 49 51
5 3 4 97 98
6 3 5 50 52
7 4 5 98 99
8 4 6 51 53
9 5 7 52 54
10 6 8 53 55
11 7 9 54 56
12 8 10 55 57
13 9 11 56 58
14 10 12 57 59
15 11 13 58 60
16 12 14 59 61
17 13 15 60 62
18 14 16 61 63
19 15 17 62 64
20 16 18 63 65
21 17 19 64 66
22 18 20 65 67
23 19 21 66 68
24 20 22 67 69
25 21 23 68 70
26 22 24 69 71
27 23 25 70 72
28 24 26 71 73
29 25 27 72 74
30 26 28 73 75
31 27 29 74 76
32 28 30 75 77
33 29 31 76 78
34 30 32 77 79
35 31 33 78 80
36 32 34 79 81
37 33 35 80 82
38 34 36 81 83
39 35 37 82 84
40 36 38 83 85
41 37 39 84 86
42 38 40 85 87
43 39 41 86 88
44 40 42 87 89
45 41 43 88 90
46 42 44 89 91
47 43 45 90 92
48 44 46 91 93
49 45 47 92 94
50 46 48 93 95
51 47 49 94 96
52 48 50 95 97
53 49 51 96 98
54 50 52 97 99
|
Posted by Daniel
on 2009-09-03 13:32:27 |