Re: Help needed



Gary Scott wrote:

LordOfNoldor wrote:

Firstly thnak you for your interest. The question is the following:

An integer is a perfect square if it is the square of another integer.
For example, 25 is a perfect square because it is 5 x 5. Write a
program to selectively print those numbers less than 100 that are not
perfect squares. Sample output for this program should look like the
following.

2
3
5
6
7
8
10
.
.
.
99

I know to find if an input number is a perfect square or not but I just
can't get to write a program for that question. It's been hours since
I've been trying and only result i get was and endless loop:(

something like:

program psq

integer :: i

do i = 1, 99

if (.not.perfsq(i)) write(*,*)i

end do

end program

logical function perfSQ

...define a logical function that returns .true. if a perfect square
oops ...and .false. if not true

end function


--

Gary Scott
mailto:garylscott@sbcglobal dot net

Fortran Library: http://www.fortranlib.com

Support the Original G95 Project: http://www.g95.org
-OR-
Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html

Why are there two? God only knows.


If you want to do the impossible, don't hire an expert because he knows it can't be done.

-- Henry Ford
.



Relevant Pages

  • Re: Help needed
    ... An integer is a perfect square if it is the square of another integer. ... ....define a logical function that returns .true. ... Support the Original G95 Project: http://www.g95.org ... Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html ...
    (comp.lang.fortran)
  • Re: NLSYST Subroutine Source
    ... Gary Scott ... Support the Original G95 Project: http://www.g95.org ... Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html ... just typing "nlsyst" in Google brought up a bunch ...
    (comp.lang.fortran)
  • Re: NLSYST Subroutine Source
    ... Gary Scott wrote: ... Support the Original G95 Project: http://www.g95.org ... Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html ... just typing "nlsyst" in Google brought up a bunch ...
    (comp.lang.fortran)
  • Re: Integer Coersion
    ... Gary Scott wrote: ... You can do a lot with this scheme, but probably not everything and you might have to reserve/define a bit for "native definition" that is logic zero so that you don't mess up the normal/pre-existing kind value definitions. ... Support the Original G95 Project: http://www.g95.org ... Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html ...
    (comp.lang.fortran)
  • Re: What would it take to have no undefined behavior in Fortran ?
    ... Gary Scott wrote: ... smallest memory that any machine might ever have. ... Support the Original G95 Project: http://www.g95.org ... Support the GNU GFortran Project: http://gcc.gnu.org/fortran/index.html ...
    (comp.lang.fortran)