ScrapExplorer - prime_number.f90

Home / misc / fortran Lines: 1 | Size: 1008 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)]
[FILE BEGIN]
1! SPDX-License-Identifier: GPL-3.0 2! Prime number 3! Calculates if a number is prime or not 4! 5! prime_number.f90 6! 7! COPYRIGHT NOTICE 8! Copyright (C) 2024-2025 0x4248 and contributors 9! This program is free software: you can redistribute it and/or modify 10! it under the terms of the GNU General Public License as published by 11! the Free Software Foundation, either version 3 of the License, or 12! (at your option) any later version. 13! 14! Redistribution and use in source and binary forms, with or without 15! modification, are permitted provided that the license is not changed. 16 17program prime_number 18 implicit none 19 integer :: n, i 20 logical :: is_prime 21 22 print *, 'Enter a number:' 23 read *, n 24 25 is_prime = .true. 26 do i = 2, n-1 27 if (mod(n, i) == 0) then 28 is_prime = .false. 29 exit 30 end if 31 end do 32 33 if (is_prime) then 34 print *, n, 'is a prime number.' 35 else 36 print *, n, 'is not a prime number.' 37 end if 38 39end program prime_number 40
[FILE END]
(C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.