Return to Snippet

Revision: 67730
at October 22, 2014 18:02 by chema_ar


Initial Code
program divisor_pattern
integer :: n = 10;
integer :: i = 1;
integer :: j = 1;
do while (i<=n)
      j = 1;
      do while (j<=n)
       if (mod(i,j)==0 .OR. mod(j,i)==0) then
          write(*,"(A)",advance="no") " *"
       else
           write(*,"(A)",advance="no") " "
       end if
         j = j + 1;
      end do
      print *,""
      i = i + 1;

end do
read *,
end program divisor_pattern

Initial URL


Initial Description
This is a piece of code to print out a divisor pattern given a number n. It is a basic exercise of programming. It should be improved protecting the code.

Initial Title
Divisor pattern

Initial Tags


Initial Language
Fortran