UVA Problem 640 ( Self Numbers) Solution

Problem Solving, UVa

UVA Problem 640 ( Self Numbers): Is a basic UVa problem.

Details link:

 

Problem Details:

This is a Straightforward problem.

 

problem solution:

#include <stdio.h>

#include <math.h>



int d[1000010];



int generator(int num)

{

    int sum = num;

    while(num > 0)

    {

        sum += num%10;

        num /= 10;

    }

    return sum;

}



int main()

{

    int i;

//for(i=1;i<=100;i++)

    for(i=1;i<=1000000;i++)

    {

        if(d[i] == 0)

            printf("%d\n",i);

        d[generator(i)] = 1;

    }



    return 0;

}

 

0 Comments

You may find interest following article

Complete Guide: Create Laravel Project in Docker Without Local Dependencies

Create Laravel Project Through Docker — No Need to Install PHP, MySQL, or Apache on Your Local Machine In this tutorial, I’ll show you how to create and run a full Laravel project using Docker containers. That means you won’t have to install PHP, MySQL, or Apache locally on your computer. By the end of this guide, you’ll have a fully functional Laravel development...