Factorial primes: Difference between revisions
Content added Content deleted
(Factorial primes in FreeBASIC) |
|||
Line 229: | Line 229: | ||
31: 546!-1 -> 14130200926141832545..99999999999999999999 [1260 digits] |
31: 546!-1 -> 14130200926141832545..99999999999999999999 [1260 digits] |
||
</pre> |
</pre> |
||
=={{header|FreeBASIC}}== |
|||
<syntaxhighlight lang="vb">#include "isprime.bas" |
|||
#include "factorial.bas" |
|||
Print "First 10 factorial primes:" |
|||
Dim As Integer found = 0, i = 1 |
|||
While found < 10 |
|||
Dim As Integer fct = factorial (i) |
|||
If isprime(fct-1) Then |
|||
found += 1 |
|||
Print Using "##: ##_! - 1 = &"; found; i; fct-1 |
|||
End If |
|||
If isprime(fct+1) Then |
|||
found += 1 |
|||
Print Using "##: ##_! + 1 = &"; found; i; fct+1 |
|||
End If |
|||
i += 1 |
|||
Wend |
|||
Sleep</syntaxhighlight> |
|||
{{out}} |
|||
<pre>First 10 factorial primes; |
|||
1: 1! + 1 = 2 |
|||
2: 2! + 1 = 3 |
|||
3: 3! - 1 = 5 |
|||
4: 3! + 1 = 7 |
|||
5: 4! - 1 = 23 |
|||
6: 6! - 1 = 719 |
|||
7: 7! - 1 = 5039 |
|||
8: 11! + 1 = 39916801 |
|||
9: 12! - 1 = 479001599 |
|||
10: 14! - 1 = 87178291199</pre> |
|||
=={{header|J}}== |
=={{header|J}}== |