ユーマちゃんのブログ

質問・要望はTwitterもしくはコメントで。返信はTwitterで。

programming report7 別ver

program report_7
implicit none
integer ::a,x,y,z,i,n=0
logical prime
write(*,*) 'Enter the limit of hypotenuse'
read(*,*) a
do z=1,a
do y=1,a-1
do x= 1, a-2
if (x**2+y**2==z**2) then
if (x<y .and. y<z)then
do i = 2,y
prime = .true.
if (mod(x,i)==0 .and. mod(y,i)==0) then
prime=.false.
exit
endif
end do
if (prime) then
n=n+1
write(*,*) n,')', x,y,z
endif
endif
endif
enddo
enddo
enddo


write(*,*) 'The total of primitive Pythagorean triples is', n
end program report_7