Skip to content

Commit 9dcc224

Browse files
committed
Generated Sample Programs website automatically
on-behalf-of: @TheRenegadeCoder <jeremy.grifski@therenegadecoder.com>
1 parent 5ee2d66 commit 9dcc224

File tree

6 files changed

+86
-98
lines changed

6 files changed

+86
-98
lines changed

docs/languages/fortran/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
date: 2018-04-25
2+
date: 2018-09-17
33
featured-image: programming-languages.jpg
44
last-modified: 2025-10-15
55
layout: default

docs/languages/index.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Here are the percentages for each language in the collection:
6060

6161
<tr>
6262
<td class="right nowrap">Php</td>
63-
<td class="right">4.09%</td>
63+
<td class="right">4.10%</td>
6464
<td class="bar-graph"><div style="width: 57.25%; background-color: #4F5D95;"></div></td>
6565
</tr>
6666

@@ -78,7 +78,7 @@ Here are the percentages for each language in the collection:
7878

7979
<tr>
8080
<td class="right nowrap">C++</td>
81-
<td class="right">3.16%</td>
81+
<td class="right">3.17%</td>
8282
<td class="bar-graph"><div style="width: 44.26%; background-color: #F34B7D;"></div></td>
8383
</tr>
8484

@@ -90,7 +90,7 @@ Here are the percentages for each language in the collection:
9090

9191
<tr>
9292
<td class="right nowrap">Mathematica</td>
93-
<td class="right">2.99%</td>
93+
<td class="right">3.00%</td>
9494
<td class="bar-graph"><div style="width: 41.89%; background-color: #DD1100;"></div></td>
9595
</tr>
9696

@@ -228,8 +228,8 @@ Here are the percentages for each language in the collection:
228228

229229
<tr>
230230
<td class="right nowrap">Fortran</td>
231-
<td class="right">0.55%</td>
232-
<td class="bar-graph"><div style="width: 7.69%; background-color: #4D41B1;"></div></td>
231+
<td class="right">0.50%</td>
232+
<td class="bar-graph"><div style="width: 6.97%; background-color: #4D41B1;"></div></td>
233233
</tr>
234234

235235
<tr>

docs/projects/hello-world/fortran/index.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
22
authors:
3-
- Jeremy Grifski
4-
date: 2018-04-25
3+
- "\u0218tefan-Iulian Alecu"
4+
date: 2025-10-15
55
featured-image: hello-world-in-every-language.jpg
6-
last-modified: 2018-04-25
6+
last-modified: 2025-10-15
77
layout: default
88
tags:
99
- fortran
@@ -29,17 +29,18 @@ Welcome to the [Hello World](https://sampleprograms.io/projects/hello-world) in
2929
{% raw %}
3030

3131
```fortran
32-
PROGRAM HELLOWORLD
33-
PRINT *, 'Hello, World!'
34-
END
32+
program helloworld
33+
implicit none
34+
print '(A)', 'Hello, World!'
35+
end program helloworld
3536
3637
```
3738

3839
{% endraw %}
3940

4041
Hello World in [Fortran](https://sampleprograms.io/languages/fortran) was written by:
4142

42-
- Jeremy Grifski
43+
- Ștefan-Iulian Alecu
4344

4445
If you see anything you'd like to change or update, [please consider contributing](https://github.com/TheRenegadeCoder/sample-programs).
4546

docs/projects/hello-world/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
date: 2018-03-15
33
featured-image: hello-world-in-every-language.jpg
4-
last-modified: 2025-08-04
4+
last-modified: 2025-10-15
55
layout: default
66
tags:
77
- hello-world

docs/projects/prime-number/fortran/index.md

Lines changed: 70 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
---
22
authors:
33
- Mallikarjuna S J
4+
- "\u0218tefan-Iulian Alecu"
45
date: 2020-10-30
56
featured-image: prime-number-in-every-language.jpg
6-
last-modified: 2020-10-30
7+
last-modified: 2025-10-15
78
layout: default
89
tags:
910
- fortran
@@ -29,89 +30,74 @@ Welcome to the [Prime Number](https://sampleprograms.io/projects/prime-number) i
2930
{% raw %}
3031

3132
```fortran
32-
! In program name, - is not allowed
33-
!works till 100938872634753805466563377840038871040
34-
! Commenting out of the reasonable bounds for calculation
3533
program prime_check
36-
character(len=10) :: argument
37-
Character(26) :: low = 'abcdefghijklmnopqrstuvwxyz'
38-
Character(26) :: cap = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
39-
integer :: check_capital_letters, check_small_letters, i, decimal_check, even_check, remainder, flag_prime
40-
integer(kind = 16):: number
41-
! Anything not equal to single argument, Print Error
42-
IF(COMMAND_ARGUMENT_COUNT().NE.1)THEN
43-
write(*,'(g0.8)')"Usage: please input a non-negative integer"
44-
STOP
45-
ENDIF
46-
47-
CALL GET_COMMAND_ARGUMENT(1,argument)
48-
if (argument == "") then
49-
write(*,'(g0.8)')"Usage: please input a non-negative integer"
50-
STOP
51-
endif
52-
! Scan for letters
53-
check_capital_letters = scan(argument, cap)
54-
check_small_letters = scan(argument, low)
55-
decimal_check = scan(argument, '.')
56-
! If capital letters exist, print error
57-
if (check_capital_letters > 0) then
58-
write(*,'(g0.8)')"Usage: please input a non-negative integer"
59-
STOP
60-
endif
61-
! If small letters exist, print error
62-
if (check_small_letters > 0) then
63-
write(*,'(g0.8)')"Usage: please input a non-negative integer"
64-
STOP
65-
endif
66-
67-
! Decimal Check
68-
if (decimal_check > 0) then
69-
write(*,'(g0.8)')"Usage: please input a non-negative integer"
70-
STOP
71-
endif
72-
! read the cmd line arg into number
73-
read (argument, '(I10)') number
74-
75-
! negative number
76-
if (number < 0) then
77-
write(*,'(g0.8)')"Usage: please input a non-negative integer"
78-
STOP
79-
endif
80-
81-
! ! Maximum Limit
82-
! if (number > 100938872634753805466563377840038871040) then
83-
! write(*,'(g0.8)')"Input is out of the reasonable bounds for calculation"
84-
! STOP
85-
! endif
86-
87-
! 2 is Prime
88-
if (number == 2) then
89-
write(*,'(g0.8)')"Prime"
90-
STOP
91-
endif
92-
! 0, 1 and even numbers are Even
93-
even_check = modulo(number, 2)
94-
if ((number == 0) .or. (number == 1) .or. ( even_check == 0 )) then
95-
write(*,'(g0.8)')"Composite"
96-
STOP
97-
endif
98-
! Check Prime
99-
max = number / 2
100-
flag_prime = 1
101-
do i = 3, max
102-
remainder = modulo(number, i)
103-
if (remainder == 0) then
104-
flag_prime = 0
105-
exit
106-
end if
107-
end do
108-
109-
if(flag_prime == 1) then
110-
write(*,'(g0.8)') "Prime"
111-
else
112-
write(*,'(g0.8)') "Composite"
113-
end if
114-
end program
34+
implicit none
35+
integer :: argc, ios, i
36+
character(len=256) :: arg
37+
integer :: number
38+
39+
argc = command_argument_count()
40+
if (argc /= 1) call usage()
41+
42+
call get_command_argument(1, arg)
43+
arg = adjustl(trim(arg))
44+
if (len_trim(arg) == 0) call usage()
45+
46+
do i = 1, len_trim(arg)
47+
if (arg(i:i) < '0' .or. arg(i:i) > '9') call usage()
48+
end do
49+
50+
read(arg, *, iostat=ios) number
51+
if (ios /= 0 .or. number < 0) call usage()
52+
53+
if (is_prime(number)) then
54+
print *, "Prime"
55+
else
56+
print *, "Composite"
57+
end if
58+
59+
contains
60+
subroutine usage()
61+
print *, "Usage: please input a non-negative integer"
62+
stop
63+
end subroutine usage
64+
65+
pure function is_prime(n) result(prime)
66+
integer, intent(in) :: n
67+
logical :: prime
68+
integer :: k, w, offsets(8)
69+
70+
! Wheel offsets for 30k + {1,7,11,13,17,19,23,29}
71+
offsets = [1, 7, 11, 13, 17, 19, 23, 29]
72+
73+
if (n < 2) then
74+
prime = .false.
75+
return
76+
elseif (n <= 3) then
77+
prime = .true.
78+
return
79+
elseif (mod(n,2) == 0 .or. mod(n,3) == 0 .or. mod(n,5) == 0) then
80+
prime = .false.
81+
return
82+
end if
83+
84+
prime = .true.
85+
w = 0
86+
k = 7 ! start from the first wheel candidate after 5
87+
88+
do while (k*k <= n)
89+
do w = 1, 8
90+
if (mod(n, k + offsets(w) - 1) == 0) then
91+
prime = .false.
92+
return
93+
end if
94+
end do
95+
k = k + 30
96+
end do
97+
98+
end function is_prime
99+
100+
end program prime_check
115101
116102
```
117103

@@ -120,6 +106,7 @@ end program
120106
Prime Number in [Fortran](https://sampleprograms.io/languages/fortran) was written by:
121107

122108
- Mallikarjuna S J
109+
- Ștefan-Iulian Alecu
123110

124111
If you see anything you'd like to change or update, [please consider contributing](https://github.com/TheRenegadeCoder/sample-programs).
125112

docs/projects/prime-number/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
date: 2018-11-16
33
featured-image: prime-number-in-every-language.jpg
4-
last-modified: 2025-10-09
4+
last-modified: 2025-10-15
55
layout: default
66
tags:
77
- prime-number

0 commit comments

Comments
 (0)