Talk:Rare numbers: Difference between revisions

m
→‎Tweaks, C++: Further syntax-highlighting fixes
m (→‎Tweaks, C++: Further syntax-highlighting fixes)
 
(3 intermediate revisions by the same user not shown)
Line 114:
of   ''rare''   numbers)   within Shyam Sunder Gupta's
<br>[http://www.shyamsundergupta.com/rare.htm <u>webpage</u>] &nbsp; have been incorporated in this REXX program.
<langsyntaxhighlight lang="rexx">/*REXX program to calculate and display an specified amount of rare numbers. */
numeric digits 20; w= digits() + digits() % 3 /*ensure enough decimal digs for calcs.*/
parse arg many start . /*obtain optional argument from the CL.*/
Line 221:
if _>=0 then do; x= _; $= $ + q
end
end /*while q>1*/; return $</langsyntaxhighlight>
Still pretty sluggish, &nbsp; like molasses in March.
 
Line 523:
square containing the combination 9 or 14 as the first/last digit.
 
<langsyntaxhighlight lang="go">package main
import (
Line 780:
bStart = time.Now() // restart block timing
}
}</langsyntaxhighlight>
{{out}}
Results on the core i7-7700 @ 3.6Ghz.
Line 864:
:I've also updated Nigel's C++ version with the same tweaks:
 
<langsyntaxhighlight lang="cpp">#include <iostream>
#include <functional>
#include <bitset>
Line 904:
int main(){
Rare(19);
}</langsyntaxhighlight>
:Compiling this with g++ brings the overall execution time down from 30 to 21 minutes in round figures. So the figures for clang or mingw may well come in at below 10 minutes now.
 
Line 924:
== Tweaks, C++ ==
Wringing out some more performance here, just over 5 minutes for 19 digits by themselves, and just over 6 minutes for digits 2 thru 19. See the code comments for details on what was tweaked. Curiously, I found that the g++ version executes faster than the clang++ version. Compiler arguments used: <code>g++ rare.cpp -o rare.exe -std=c++17 -O3</code><br/>Curious to see if it can go faster on a different platform - But the original executed faster on g++ than clang++ for me on my platform too. Perhaps I don't have clang++ set up the same as others?
<langsyntaxhighlight lang="cpp">// Rare Numbers : Nigel Galloway - December 20th., 2019
 
/*
Line 1,060:
printf("%4s %19s %11s %10s %5s %11s %9s\n", "nth", "forward", "rt.sum", "rt.diff", "digs", "block.et", "total.et");
for (int nd = 2; nd <= max; nd++) Rare(int(nd));
}</langsyntaxhighlight>
{{out}}
Results on the core i7-7700 @ 3.6Ghz.
35

edits