Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
特定の範囲 (10 億から 30 億) で N と言う数字で完全に割り切れるすべての数字を見つけるための C++ プログラムを作成しようとしています。
非常に基本的な:
for (i = 0; i < 3 BIllion; i++) { if (i % N == 0) print (i); }
これには長い時間がかかるため、より良い解決策があると確信しています。正しい方向に微調整していただければ幸いです。
すべての数を順番にテストするのではなく、倍数を明示的に生成しないのはなぜですか?
#include <cstdint> uint32_t i = 0; while (i < 3000000000) { printf("%d\n", i); i += N; }