Factorial primes: Difference between revisions

m
no edit summary
mNo edit summary
Line 1,451:
469! - 1 = 67718096668149510900...99999999999999999999
</pre>
 
=={{header|V (Vlang)}}==
<syntaxhighlight lang="Zig">
import math
 
fn main() {
mut n, mut count := 0, 0
for count < 10 {
n++
f := math.factoriali(n)
if is_prime(f - 1) {
count++
println("${count}: ${n}! - 1 = ${f - 1}")
}
if is_prime(f + 1) {
count++
println("${count}: ${n}! + 1 = ${f + 1}")
}
}
}
 
fn is_prime(num i64) bool {
if num <= 1 {return false}
if num % 2 == 0 && num != 2 {return false}
for idx := 3; idx <= math.floor(num / 2) - 1; idx += 2 {
if num % idx == 0 {return false}
}
return true
}
</syntaxhighlight>
 
{{out}}
<pre>
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|Wren}}==
===Basic===
291

edits