@Payel: Fermat's theorem on the sum of two squares applies. It says that an odd prime p can be written as the sum of two perfect squares if and only if p is congruent to 1 (mod 4). See http://en.wikipedia.org/wiki/Proofs_of_Fermat's_theorem_on_sums_of_two_squares.
Thus, since 29 is congruent to 1 (mod 4), it can be written as the sum of two squares, as you have demonstrated. But, e.g., 7, 11, and 19 cannot be written as the sum of two perfect squares. Code follows: int PrimeIsSumOfTwoSquares(int p) { return (p & 3) == 1; } Dave On Saturday, June 2, 2012 2:31:43 PM UTC-5, payel roy wrote: > How do you verify whether sides of rectangular area are integer number If > square of diagonal of a rectangular area is prime? > > Ex : Let's say square of a diagonal is : 2 > > 2 = 1^2 + 1^2 [where 1,1 are the sides of the rectangular area] > > square of a diagonal is : 29 > > 29 = 5^2 + 2^2. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/wVxBh-kN-LoJ. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.