@payel : you have mentioned sum of square of diagonal of rectangle.. but as
you can see that 29 can't be the sum of square of diagonal of any
rectangle.. because for a rectangle both diagonal would be equal...
so sum shoud be 2 * diagonal^2...
please explain your que..

On Sun, Jun 3, 2012 at 1:28 AM, Dave <dave_and_da...@juno.com> wrote:

> @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.
>



-- 
Thanks and Regards:
Rahul Kumar Patle
M.Tech, School of Information Technology
Indian Institute of Technology, Kharagpur-721302, India
Mobile No: +91-8798049298, +91-9424738542
patlerahulku...@gmail.com
rahulkumarpa...@yahoo.com

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
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.

Reply via email to