Multiplicative Persistence
I watched a video on Numberphile about the concept of multiplicative persistence, which is the number of times you need to multiply the digits of a number together until you reach a single digit. I was fascinated by this idea and decided to create a simple web application to calculate the multiplicative persistence of any number.
I made a first version of the application using C++, which was very fast, but didn't have a user friendly interface. That's why I decided to create an interface using Dear ImGui.
The application saves the results in a JSON file, which is saved when the application is closed and loaded when the application is started. This way, the user can see the results of previous calculations and continue from where they left off.
This was my first time using Dear ImGui, and I found it very easy to use once I got the hang of it.
If you want to try the application, you can download it from my GitHub repository.
CPU & GPU Acceleration
As part of a university lab, I accelerated the multiplicative persistence search using OpenMP across 16 CPU threads and CUDA on an NVIDIA RTX 3070 (5,888 cores). The goal: process as many numbers as possible in a fixed 60-second window. A grid-stride CUDA kernel combined with conditional atomics — checking the current value before writing — cut unnecessary memory contention by over 90%, pushing throughput to tens of billions of numbers per second.
| Implementation | Numbers / sec | Speedup |
|---|---|---|
| CPU Sequential | 60.5 M | 1× |
| OpenMP (16 threads) | 722 M | ~12× |
| CUDA (RTX 3070) | 14.7 B | ~242× |
| CUDA AI-optimized | 16.4 B | ~271× |