-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProblem-27.nb
100 lines (91 loc) · 3.16 KB
/
Problem-27.nb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
(* Content-type: application/mathematica *)
(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)
(* CreatedBy='Mathematica 7.0' *)
(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[ 145, 7]
NotebookDataLength[ 3044, 90]
NotebookOptionsPosition[ 2720, 74]
NotebookOutlinePosition[ 3063, 89]
CellTagsIndexPosition[ 3020, 86]
WindowFrame->Normal*)
(* Beginning of Notebook Content *)
Notebook[{
Cell[CellGroupData[{
Cell[BoxData[{
RowBox[{
RowBox[{"ans", " ", "=", " ", "0"}], ";"}], "\[IndentingNewLine]",
RowBox[{
RowBox[{"value", " ", "=", " ", "0"}], ";"}], "\[IndentingNewLine]",
RowBox[{"For", "[",
RowBox[{
RowBox[{"a", " ", "=", " ",
RowBox[{"-", "1000"}]}], " ", ",", " ",
RowBox[{"a", " ", "\[LessEqual]", " ", "1000"}], " ", ",", " ",
RowBox[{
RowBox[{"a", " ", "++"}], " ", "\[IndentingNewLine]", "[", " ",
"\[IndentingNewLine]", "\t",
RowBox[{"For", "[",
RowBox[{
RowBox[{"b", " ", "=", " ",
RowBox[{"-", "1000"}]}], " ", ",", " ",
RowBox[{"b", " ", "\[LessEqual]", " ", "1000"}], " ", ",", " ",
RowBox[{"b", " ", "++"}], ",", " ", "\[IndentingNewLine]", "\t",
RowBox[{
RowBox[{"temp", " ", "=", " ", "0"}], ";", "\[IndentingNewLine]", "\t",
RowBox[{"While", "[", " ",
RowBox[{
RowBox[{
RowBox[{"PrimeQ", " ", "[",
RowBox[{
RowBox[{"temp", " ", "*", " ", "temp"}], " ", "+", " ",
RowBox[{"a", " ", "*", " ", "temp"}], " ", "+", " ", "b"}], " ",
"]"}], " ", "\[Equal]", " ", "True"}], " ", ",", " ",
RowBox[{"temp", " ", "++"}]}], "]"}], ";", "\[IndentingNewLine]",
" ",
RowBox[{"If", " ", "[",
RowBox[{
RowBox[{"temp", " ", ">", " ", "value"}], " ", ",", " ",
RowBox[{
RowBox[{"value", " ", "=", " ", "temp"}], " ", ";", " ",
RowBox[{"ans", " ", "=", " ",
RowBox[{"a", " ", "*", " ", "b"}]}]}]}], "]"}]}]}],
"\[IndentingNewLine]", "\[IndentingNewLine]", "\t", "]"}],
"\[IndentingNewLine]", "\t\t", "\[IndentingNewLine]", " ", "]"}]}],
"\[IndentingNewLine]", "]"}], "\[IndentingNewLine]",
RowBox[{"Print", "[", "ans", "]"}]}], "Input",
CellChangeTimes->{{3.494313225435437*^9, 3.4943133186127663`*^9}, {
3.494313382805438*^9, 3.4943134910926313`*^9}, {3.494313529959855*^9,
3.4943135790966654`*^9}}],
Cell[BoxData[
RowBox[{"-", "59231"}]], "Print",
CellChangeTimes->{{3.494313554228243*^9, 3.4943135756874704`*^9},
3.494313611057493*^9}]
}, Open ]]
},
WindowSize->{607, 549},
WindowMargins->{{0, Automatic}, {Automatic, 0}},
FrontEndVersion->"7.0 for Microsoft Windows (32-bit) (November 10, 2008)",
StyleDefinitions->"Default.nb"
]
(* End of Notebook Content *)
(* Internal cache information *)
(*CellTagsOutline
CellTagsIndex->{}
*)
(*CellTagsIndex
CellTagsIndex->{}
*)
(*NotebookFileOutline
Notebook[{
Cell[CellGroupData[{
Cell[567, 22, 1992, 44, 292, "Input"],
Cell[2562, 68, 142, 3, 23, "Print"]
}, Open ]]
}
]
*)
(* End of internal cache information *)