Like Tree9Likes
  • 3 Post By quzah
  • 2 Post By quzah
  • 3 Post By CommonTater
  • 1 Post By iMalc

Operations on numbers

This is a discussion on Operations on numbers within the C Programming forums, part of the General Programming Boards category; I would like all the members here take part in this and contribute to this simple thread...... We all think ...

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    52

    Operations on numbers

    I would like all the members here take part in this and contribute to this simple thread......


    We all think differently....so we ll have different solutions to this simple problem.


    I am searching for different logics that would generate the following numbers in an arbitary range say between UpperLimit and LowerLimit. (int UL,LL).

    1. Armstrong Number

    *2. Magic / Ramanujan Number [http://www.quickermaths.com/ramanujan-number/] << This is more important for me.

    3. Krishnamurthy Number [A krishnamurthy number is one whose sum of the factorials of each number is equal to the number itself. Eg: 145]

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    1,625
    Have you tried printing all the prime numbers between 10 pairs of values in less than 6 seconds, using an old Pentium II 700MHz processor?
    Devoted my life to programming...

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    I will translate for you:
    Quote Originally Posted by Avenger625 View Post
    I would like all the members here take part in this and contribute to this simple thread......
    I would like to have this done for me.
    Quote Originally Posted by Avenger625 View Post
    We all think differently....so we ll have different solutions to this simple problem.
    By "we" I mean "you", because I don't actually have any solutions, which is why I'm posting this.
    Quote Originally Posted by Avenger625 View Post
    I am searching for different logics
    I am searching for the actual full working program, because if all I wanted was the "logics" behind it, I would have found it on Google by now.
    Quote Originally Posted by Avenger625 View Post
    *2. Magic / Ramanujan Number [http://www.quickermaths.com/ramanujan-number/] << This is more important for me.
    This is my homework, so give me this one first!


    Quzah.
    Hope is the first step on the road to disappointment.

  4. #4
    Registered User
    Join Date
    Feb 2011
    Posts
    52
    Quote Originally Posted by Avenger625 View Post
    I am searching for different logics
    I am searching for the actual full working program, because if all I wanted was the "logics" behind it, I would have found it on Google by now.
    Lemme add it to ur knowledge that u also get "full working program" on Google....Google it out....m sure u ll find a bunch of codes!!!

    I was "actually" searching for various approaches and/or logics solving those problems!!!

    Quote Originally Posted by Avenger625 View Post
    *2. Magic / Ramanujan Number [http://www.quickermaths.com/ramanujan-number/] << This is more important for me.


    This is my homework, so give me this one first!
    If at all its my homework even then how does it bother you anyway if you do it on my behalf and help an ignorant kid to save his ass rather than "mis"-interpreting and translating my statements???

    The second one is my homework that's why i posted it here and wanted it to be urgently done...that's what you had to say??!! Then why did I post the first and third one????

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Avenger625 View Post
    Lemme add it to ur knowledge that u also get "full working program" on Google....Google it out....m sure u ll find a bunch of codes!!!
    Of course I will. Hell, if I search for magic square here I get 70 threads.
    Quote Originally Posted by Avenger625 View Post
    I was "actually" searching for various approaches and/or logics solving those problems!!!
    No you weren't. You weren't looking for the logic behind it either, because you would have found it on Wikipedia in 2 seconds by typing in magic square.
    Quote Originally Posted by Avenger625 View Post
    If at all its my homework even then how does it bother you anyway if you do it on my behalf
    Read the homework policy. If I do it for you, you are still:
    Quote Originally Posted by Avenger625 View Post
    an ignorant kid
    Doing it for you doesn't cure ignorance.
    Quote Originally Posted by Avenger625 View Post
    The second one is my homework that's why i posted it here and wanted it to be urgently done...that's what you had to say??!! Then why did I post the first and third one????
    Maybe that one is due first. Or maybe the other two are extra credit. The fact is, you didn't read the homework policy, and you didn't post anything other than "come post here and do this for me".


    Quzah.
    Hope is the first step on the road to disappointment.

  6. #6
    Banned
    Join Date
    Aug 2010
    Location
    Ontario Canada
    Posts
    9,547
    Quote Originally Posted by Avenger625 View Post
    If at all its my homework even then how does it bother you anyway if you do it on my behalf and help an ignorant kid to save his ass rather than "mis"-interpreting and translating my statements???
    Because you won't learn a darned thing from the "gifted code", but you'll pass your course and then one of us will get stuck with you asking us to cover your butt in the workplace later on... And I for one would absolutly not want you in my workgroup.

    If you're going to take a programming course then you should learn to program. You should not be wasting our time while you learn how to beg.

    The second one is my homework that's why i posted it here and wanted it to be urgently done...that's what you had to say??!! Then why did I post the first and third one????
    Here... read this... Homework Policy ...

    As with all people asking for help... show some initiative, post your code... If you are actually stuck (not lazy stuck) maybe we'll help you along. No initiative on your part? Well, there are lots of other forums you can try.
    quzah, ardavirus and Salem like this.

  7. #7
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,308
    Avenger625, you can try and defend yourself all you like, but until you're respected the homework policy by posting actual code that we can help with, you'll probably just get mocked for not doing so. Respect the system and others will respect you. It doesn't matter what you say until you post some code of demonstrate that you're wanting some specific knowledge about a specific piece of coding you are stuck on. You must ask a specific question.
    ardavirus likes this.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  8. #8
    Registered User
    Join Date
    Feb 2011
    Posts
    52
    @ quzah: I see u are equally dumb as me....U always temme clicking arround google and wiki but u urself refrain to click a link beside "2". Did u realise i'm not behind "Magic Square"....click the link find out...!!!
    @ all others: It WAS NOT my homework....i "REALLY" wanted different approaches solving those problems!!!
    I said, "If at all it’s my homework even then how does it bother you anyway if you do it on my behalf and help an ignorant kid to save his ass rather than "mis"-interpreting and translating my statements???"
    I meant, is not it waste of time to dissect whether it was someone's homework or something rather than posting some codes. quzah was so very sure that it was my homework so i said, thinking it to be my homework only, let him post his logic!!!

    CommonTater:
    Because you won't learn a darned thing from the "gifted code", but you'll pass your course and then one of us will get stuck with you asking us to cover your butt in the workplace later on... And I for one would absolutly not want you in my workgroup.
    Don't you think C has become outdated for real-world development in the current scenario?? I will not say there are none but hardly there are organisations who develop using C. Everyone is running behind .NET and Java these days. And about my programming skills, I know what I can do and I know I will be hired without anyone covering my butt!!



    So, to all u nerds....here is my logic..........

    Code:
      //krishnamurthy
    
    #include <stdio.h>
    
    int fact(int);
    
    int main()
    {
    	int u,l,t,s,i;
       printf("Enter lower limit : ");
       scanf("%d",&l);
       printf("Enter upper limit : ");
       scanf("%d",&u);
       for(i=l;i<=u;i++)
       {
       	t=i;
          s=0;
       	while(t!=0)
       	{
          	s=s+fact(t%10);
       		t=t/10;
       	}
       	if(s==i)
       		printf("%d ",i);
       }
    }
    
    int fact(int n)
    {
    	return n==0?1:n*fact(n-1);
    }
    Code:
      //Armstrong
    
    #include <stdio.h>
    #include <math.h>
    
    int main(void)
    {	
    	int l,u,i,t,d,s;
     	printf("Enter lower limit : ");
       	scanf("%d",&l);
       	printf("Enter upper limit : ");
       	scanf("%d",&u);
       	for(i=l;i<=u;i++)
       	{
       		t=i;
         		d=0;
       		while(t!=0)
          		{
          			d++;
             		t/=10;
          		}
          		t=i;
          		s=0;
          		while(t!=0)
          		{
          			s+=(int)pow(t%10,d);
             		t/=10;
          		}
          		if(i==s)
          			printf("%d ",i);
       	}
       	
    }
    I'm still working on the "Magic No." algorithm....its taking hell lot of time and its buggy too......look forward to post it soon.


    From you nerds, I would like some better and optimized logic than those I posted
    Last edited by Avenger625; 06-20-2011 at 01:18 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 09-08-2010, 10:26 AM
  2. Doing operations with very large numbers?
    By thefeedinghand in forum C++ Programming
    Replies: 4
    Last Post: 07-30-2010, 12:25 AM
  3. Operations with negative/decimal numbers?
    By Dominus Casuum in forum C++ Programming
    Replies: 6
    Last Post: 01-12-2007, 11:48 PM
  4. Comparing numbers to a list of numbers held in a text file
    By jmajeremy in forum C++ Programming
    Replies: 3
    Last Post: 11-06-2006, 06:56 AM
  5. doing floating operations using integer operations
    By ammalik in forum C Programming
    Replies: 10
    Last Post: 08-15-2006, 04:30 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21