Thread: kardışık number

  1. #1
    Registered User
    Join Date
    Mar 2016
    Posts
    3

    kardışık number

    sample:
    13 = 22 + 32
    14 = 12 + 22 + 32

    In this context, it entered between 1 and 9999 (if a larger or smaller number entered will be given a warning) whether a number kardışık number, and that number is the sum of what number you kardışık developed by the c program.
    sample entries: 421
    sample output: 14 – 15

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,738
    Google translate has seen better days...
    Devoted my life to programming...

  3. #3
    Registered User
    Join Date
    Jun 2015
    Posts
    1,640
    Quote Originally Posted by Tuğba Yılmaz View Post
    sample:
    13 = 22 + 32
    14 = 12 + 22 + 32

    In this context, it entered between 1 and 9999 (if a larger or smaller number entered will be given a warning) whether a number kardışık number, and that number is the sum of what number you kardışık developed by the c program.
    sample entries: 421
    sample output: 14 – 15
    Sounds simple enough. What have you tried? What are you having trouble with? Post some code.

    BTW, does anyone know what these numbers are called in English? Google translate doesn't seem to know.

  4. #4
    Registered User
    Join Date
    Mar 2016
    Posts
    3
    Code:
    
    
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    
    main()
    {
      long int a,n,s1,s2,o;
      label: printf("Enter the number: ");
      scanf("%ld",&a);
      if (a<1 || a>9999)
      {
        printf("\n please enter 1 between 9999 number!\n\n");
        goto label;
      }
      for (n=1;n<a;++n)
      {
        s1=n*n;
        s2=(n+1)*(n+1);
        o=s1+s2;
    
    
        if(o==a){
           printf("\n numbers: %ld,%2ld",n,n+1);
        }
    
    
      }
    
    
      printf("\n\n");
    }
    not working 14 = 12 + 22 + 32
    Last edited by Tuğba Yılmaz; 03-27-2016 at 12:44 PM.

  5. #5
    Registered User
    Join Date
    Jun 2015
    Posts
    1,640
    You must know why your code isn't working for the given example. Your code only tests for two numbers in a row but your example needs three. Instead of a fixed number you'll need another loop.

    So these so-called "kardışık numbers" (we still don't have a translation here) are numbers that can be represented as the sum of the squares of consecutive integers? Are the squares themselves "kardışık numbers"?

  6. #6
    Registered User
    Join Date
    Sep 2014
    Posts
    364
    A "kardışık number" means "pyramid number"
    Link: https://en.wikipedia.org/wiki/Square_pyramidal_number
    Other have classes, we are class

  7. #7
    Registered User
    Join Date
    Jun 2011
    Posts
    4,513
    You should not be using goto. It is more appropriate to use a loop for that purpose.

  8. #8
    Registered User
    Join Date
    Mar 2016
    Posts
    3
    Code:
    main()
    {
      long int a,n,s1,s2,o;
      label: printf("Enter the number: ");
      scanf("%ld",&a);
      if (a<1 || a>9999)
      {
        printf("\n please enter 1 between 9999 number!\n\n");
        goto label;
      }
      for (n=1;n<a;++n)
      {
        s1=(n*n)+((n+1)*(n+1));
        s2=(n+2)*(n+2);
        o=s1+s2;
        if(s1==a){
           printf("\n numbers: %ld,%ld",n,n+1);
        }
        else if(o==a){
           printf("\n numbers: %ld,%ld,%ld",n,n+1,n+2);
        }
      }
      printf("\n\n");
    }

    Alright thanks a lot I got it.
    Thanks a lot guys/gals.

  9. #9
    Registered User
    Join Date
    Sep 2010
    Location
    Europe
    Posts
    87
    Quote Originally Posted by WoodSTokk View Post
    A "kardışık number" means "pyramid number"
    Link: https://en.wikipedia.org/wiki/Square_pyramidal_number
    It does not mean "pyramid number".

    Pyramid number is defined as a sum P_n=1^2+2^2+3^2+...+n^2, while this guy has for entry 421 output 14, 15 (14^2+15^2, which is a difference P_15-P_13, and no pyramid number directly).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 09-30-2015, 09:15 AM
  2. Replies: 14
    Last Post: 06-26-2015, 03:58 PM
  3. Convert 8-digit Binary Number to decimal number
    By yongsheng94 in forum C++ Programming
    Replies: 2
    Last Post: 07-06-2013, 09:47 AM
  4. Input a Hex number and output hex number to a text field
    By zoobaby in forum C++ Programming
    Replies: 4
    Last Post: 05-12-2009, 11:26 AM
  5. Random Number problem in number guessing game...
    By -leech- in forum Windows Programming
    Replies: 8
    Last Post: 01-15-2002, 05:00 PM