Honaker primes: Difference between revisions

Initial FutureBasic task solution added
(→‎{{header|Nim}}: added {{header|Free Pascal}} checking https://www.numbersaplenty.com/set/Honaker_prime/ for 30000101111)
(Initial FutureBasic task solution added)
Line 603:
 
10000th honaker prime is at 286069 and is 4043749</pre>
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
local fn dig_sum( n as NSUInteger )
NSUInteger sum = 0
while ( n > 0 )
sum += n mod 10
n /= 10
wend
end fn = sum
 
void local fn CalculaterHonakerPrimes
NSUInteger x, y, rank = 1, place = 0
for x = 3 to _limit step 2
if ( prime(x) == 0 )
for y = x * x to _limit step x + x
prime(y) = 1
next
end if
next
printf @"The first %lu Honaker Primes ranked as \"Index: ([position], [value])\" are:\n", 50
for x = 3 to _limit step 2
if ( prime(x) == 0 )
rank++
if ( (rank mod 9) == ( x mod 9 ) )
if ( fn dig_sum(rank) == fn dig_sum(x) )
place++
if ( place <= 50 )
printf @"%4lu: (%3lu, %4lu) \b", place, rank, x
if ( place mod 5 == 0 ) then print
end if
if ( place == 10000 ) then printf @"\n The 10000th Honaker Prime is:\n %lu: (%4lu, %5lu)", place, rank, x
end if
end if
end if
next
end fn
 
window 1, @"Honakeer Primes", ( 0, 0, 780, 380 )
 
fn CalculaterHonakerPrimes
 
HandleEvents
</syntaxhighlight>
{{output}}
<pre>
The first 50 Honaker Primes ranked as "Index: ([position], [value])" are:
 
1: ( 32, 131) 2: ( 56, 263) 3: ( 88, 457) 4: (175, 1039) 5: (176, 1049)
6: (182, 1091) 7: (212, 1301) 8: (218, 1361) 9: (227, 1433) 10: (248, 1571)
11: (293, 1913) 12: (295, 1933) 13: (323, 2141) 14: (331, 2221) 15: (338, 2273)
16: (362, 2441) 17: (377, 2591) 18: (386, 2663) 19: (394, 2707) 20: (397, 2719)
21: (398, 2729) 22: (409, 2803) 23: (439, 3067) 24: (446, 3137) 25: (457, 3229)
26: (481, 3433) 27: (499, 3559) 28: (508, 3631) 29: (563, 4091) 30: (571, 4153)
31: (595, 4357) 32: (599, 4397) 33: (635, 4703) 34: (637, 4723) 35: (655, 4903)
36: (671, 5009) 37: (728, 5507) 38: (751, 5701) 39: (752, 5711) 40: (755, 5741)
41: (761, 5801) 42: (767, 5843) 43: (779, 5927) 44: (820, 6301) 45: (821, 6311)
46: (826, 6343) 47: (827, 6353) 48: (847, 6553) 49: (848, 6563) 50: (857, 6653)
 
The 10000th Honaker Prime is:
10000: (286069, 4043749)
</pre>
 
 
=={{header|Go}}==
729

edits